AssertionError:HybridBlock要求将第一个参数转发为Symbol或NDArray,但得到<class'numpy.ndarray'>

时间:2019-07-24 00:30:25

标签: python image numpy image-processing numpy-ndarray

我正在尝试在图像上运行一个预制程序,并且图像类型是一个numpy数组。当我按回车键时,出现此错误:

AssertionError: HybridBlock requires the first argument to forward be
                either Symbol or NDArray, but got < class 'numpy.ndarray' >

有人知道如何解密吗?当我在网上查看时,它说NDArraynumpy.ndarray,所以我不确定为什么会抱怨。非常感谢你!

1 个答案:

答案 0 :(得分:1)

您必须convert your numpy array to an mxnet NDArray

In [11]: import numpy as np

In [12]: import mxnet as mx

In [13]: a = np.array([1, 2, 3])

In [14]: b = mx.ndarray.array(a)

In [15]: b
Out[15]:

[1. 2. 3.]
<NDArray 3 @cpu(0)>

In [16]: type(b)
Out[16]: mxnet.ndarray.ndarray.NDArray