TypeError: data type not understood
这个错误有时候会在python中进行矩阵表示的时候出现,如下面的形式:
##这是个错误的例子:
np.matrix([1, 0],
[0, 1])
这样的就会出现上述错误。
解决方法是在()中加入一个[](如下面代码中的红色部分),即表示为:
##这是个正确的例子
np.matrix( [ [1, 0],
[0, 1] ] )
##这是个错误的例子:
np.matrix([1, 0],
[0, 1])
##这是个正确的例子
np.matrix( [ [1, 0],
[0, 1] ] )