64位架构的32位操作系统:计算差异?
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了64位架构的32位操作系统:计算差异?相关的知识,希望对你有一定的参考价值。
我目前正在研究python 3,特别是我正在尝试使用librosa模块来计算Raspberry pi 3模型B(使用自定义Linux发行版32位)中的mel过滤后的频谱。用于计算的代码,数据和参数与我在PC上使用的代码,数据和参数完全相同(Ubuntu 14.04 64位)。乍一看,我认为这是一个在板内运行的librosa模块的错误,所以开始检查功能是否提供与PC相同的结果。为此,我调试了“melspectogram”函数的代码(Librosa的一部分)。代码如下:
def melspectrogram(y=None, sr=22050, S=None, n_fft=2048, hop_length=512,
power=2.0, **kwargs):
S, n_fft = _spectrogram(y=y, S=S, n_fft=n_fft, hop_length=hop_length,
power=power)
# Build a Mel filter
mel_basis = filters.mel(sr, n_fft, **kwargs)
return np.dot(mel_basis, S)
函数“_spectrogram”和“filters.mel()”在Raspberry中给出了正确的结果。问题似乎是在numpy dot产品中,它为某些索引返回完全错误的结果。这是PC和电路板之间所有差异的调试视图。
###### DEBUG START-END: 206-223
PC BOARD
DIFFERENCE: (48, 11) 0.2191838420044883 != 0.21918384200448832
DIFFERENCE: (48, 15) 19.153408522395306 != 19.15340852239531
DIFFERENCE: (48, 17) 5.670882080544281 != 5.670882080544282
DIFFERENCE: (48, 24) 10.492875862139803 != 10.492875862139805
DIFFERENCE: (48, 25) 12.302969461756339 != 12.30296946175634
DIFFERENCE: (48, 26) 27.631040740403733 != 27.63104074040373
DIFFERENCE: (48, 29) 5.139375749153835 != 5.139375749153836
DIFFERENCE: (48, 34) 7.724733224346115 != 7.7247332243461155
DIFFERENCE: (48, 40) 0.09762231547647067 != 0.09762231547647066
DIFFERENCE: (49, 4) 0.011647182215426476 != 0.023294364430852952
DIFFERENCE: (49, 5) 0.011647182215426476 != 0.023294364430852952
DIFFERENCE: (49, 6) 0.011647182215426476 != 0.023294364430852952
DIFFERENCE: (49, 7) 0.011647182215426476 != 0.023294364430852952
DIFFERENCE: (49, 8) 0.011647182215426476 != 0.023294364430852952
DIFFERENCE: (49, 9) 0.024662982979241885 != 0.03631016519466836
DIFFERENCE: (49, 10) 0.011647182215426476 != 1736.0081098705543
DIFFERENCE: (49, 11) 0.011647182215426476 != 192.99921646614675
DIFFERENCE: (49, 12) 1.2357100597784794 != 1835.7802873745509
DIFFERENCE: (50, 4) 0.01162755916968538 != 0.02325511833937076
DIFFERENCE: (50, 5) 0.01162755916968538 != 0.02325511833937076
DIFFERENCE: (50, 6) 0.01162755916968538 != 0.02325511833937076
DIFFERENCE: (50, 7) 0.01162755916968538 != 0.02325511833937076
DIFFERENCE: (50, 8) 0.01162755916968538 != 0.02325511833937076
DIFFERENCE: (50, 9) 0.05210700691405087 != 333.83850661974526
DIFFERENCE: (50, 10) 0.021008006026422096 != 3965.2472056464244
DIFFERENCE: (50, 11) 0.10780954139916578 != 1530.5278140594276
DIFFERENCE: (50, 12) 0.41251995176336065 != 606.056179725736
DIFFERENCE: (51, 4) 0.011622992280708504 != 0.023245984561417007
DIFFERENCE: (51, 5) 0.011622992280708504 != 0.023245984561417007
DIFFERENCE: (51, 6) 0.011622992280708504 != 69.0566858320545
DIFFERENCE: (51, 7) 0.011622992280708504 != 825.1101267685075
DIFFERENCE: (51, 8) 0.011622992280708504 != 83.02070759794061
DIFFERENCE: (51, 9) 0.011622992280708504 != 931.8205273506092
DIFFERENCE: (51, 10) 0.4501778264666223 != 623.5746140044275
DIFFERENCE: (51, 11) 0.042509683378604 != 1987.8635720924942
DIFFERENCE: (51, 12) 1.884975416295644 != 450.9067305393012
DIFFERENCE: (52, 4) 0.01157539610226416 != 0.02315079220452832
DIFFERENCE: (52, 5) 0.01157539610226416 != 0.02315079220452832
DIFFERENCE: (52, 6) 0.01157539610226416 != 15.369480003003801
DIFFERENCE: (52, 7) 0.01157539610226416 != 183.44230139508068
DIFFERENCE: (52, 8) 0.01157539610226416 != 22.103013355309322
DIFFERENCE: (52, 9) 0.01157539610226416 != 16.947300443667636
DIFFERENCE: (52, 10) 0.7210348336411665 != 0.7326102297434307
DIFFERENCE: (52, 11) 0.07624676888597205 != 38.69928692732359
DIFFERENCE: (52, 12) 1.227613362577455 != 146.59676772956414
DIFFERENCE: (59, 4) 0.011639905409540543 != 0.023279810819081086
DIFFERENCE: (59, 5) 0.011639905409540543 != 0.023279810819081086
DIFFERENCE: (59, 6) 0.011639905409540543 != 0.023279810819081086
DIFFERENCE: (59, 7) 0.011639905409540543 != 0.023279810819081086
DIFFERENCE: (59, 8) 0.011639905409540543 != 0.023279810819081086
DIFFERENCE: (59, 9) 0.015804205007430926 != 0.02744411041697147
DIFFERENCE: (59, 10) 0.011639905409540543 != 4.896282342021101
DIFFERENCE: (59, 11) 0.024309464524604488 != 3.1951156889432926
DIFFERENCE: (59, 12) 0.014833562550355634 != 6.938331348819726
用于操作的矩阵是60x129和129x49。然后我只拿了一片矩阵(特别是S的第8列和第48和49行的mel_basis),结果如下:
DIFFERENCE: (0, 0) 0.011617925176483229 != 0.011617925176483227
DIFFERENCE: (1, 0) 0.011647182215426474 != 0.011647182215426476
然后另一个尝试与mel_basis行49和50,相同的s:
DIFFERENCE: (0, 0) 0.011647182215426474 != 0.011647182215426476
DIFFERENCE: (1, 0) 0.011627559169685383 != 0.01162755916968538
一般来说,如果我们减少计算,错误似乎会更小。
最后,为了检查,我采用了Raspberry计算的结构S和mel_basis并计算了PC中的点积。结果是正确的。它让我觉得这是与硬件相关的东西,也许与浮点有关,即使这很奇怪,因为ARM Cortex A53完全符合IEEE 754标准。 32位操作系统可以有所作为吗?
有很多可能的问题:
在PC上,它取决于程序使用哪种浮点硬件。本机x87使用内部80位扩展浮点数,如果在每次操作后都没有转换和存储结果 - 这将导致一些差异。
Python解释器可以使用float数学的不同实现。如果使用相同的编译器编译相同的Python解释器但具有不同的编译选项,则甚至可能会产生稍微不同的结果。
以上是关于64位架构的32位操作系统:计算差异?的主要内容,如果未能解决你的问题,请参考以下文章