scipy.convolve gives "ValueError: object too deep for desired array" with 3D array and 3D kernel

scipy.convolve gives "ValueError: object too deep for desired array" with 3D array and 3D kernel

我在 CentOS 7 上的 Anacona Spyder 上使用 Python 3。

下面调用

scipy.convolve(nda, box)

给出以下错误信息。

ValueError: object too deep for desired array

nda 和 box 具有相同的类型和尺寸。

np.shape(nda)
Out[51]: (70, 70, 70)

np.shape(box)
Out[52]: (3, 3, 3)

type(nda)
Out[53]: numpy.ndarray

type(box)
Out[54]: numpy.ndarray

据我了解,scipy.convolve 可以处理多维对象。我无法理解此错误消息。

名称scipy.convolvenumpy.convolve的别名,NumPy版本只接受一维输入。 (这种潜在的混淆是 SciPy 反对在 scipy 命名空间中使用 NumPy 名称的原因之一。)

你可能想要 scipy.ndimage.convolve or scipy.signal.convolve。 (为什么 SciPy 在两个子包中独立实现 convolve 是一个完整的“另一个话题”。)