Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/345.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python TypeError:无法理解数据类型,numpy.zeros_Python_Numpy_For Loop_Typeerror_Zero - Fatal编程技术网

Python TypeError:无法理解数据类型,numpy.zeros

Python TypeError:无法理解数据类型,numpy.zeros,python,numpy,for-loop,typeerror,zero,Python,Numpy,For Loop,Typeerror,Zero,我在运行代码时出错。我收到的错误是: Traceback (most recent call last): File "/Users/penguin/PycharmProjects/Greatness/venv/Recipes.py", line 153, in <module> newRatios = np.zeros(count,count) TypeError: data type not understood Process finished with exit code

我在运行代码时出错。我收到的错误是:

Traceback (most recent call last):
File "/Users/penguin/PycharmProjects/Greatness/venv/Recipes.py", line 
153, in <module>
newRatios = np.zeros(count,count)
TypeError: data type not understood

Process finished with exit code 1
变量计数表示大约5000的整数值。很抱歉,我只能提供代码片段,而不是整个文件,但我不允许透露完整的文件


我不太清楚为什么会出现这个错误,我尝试了几种不同的方法来设置numpy零点数组和设置2D矩阵。请注意,我将numpy作为np导入,因此它被称为np。我正在使用python3,如果您对设置2D阵列和访问它有任何其他建议,并且比我这里的更好,我们也将不胜感激

您需要传入一个元组。尝试
np.zero((计数,计数))


有关此方法的更多文档,请参见:使用INT序列:

newRatios = np.zeros((count,count))

零的形状参数
接受整数或整数序列。请参阅。

np.zeros
接受iterable作为形状参数。您需要将参数传递为
np.zero((count,count))
。注意额外的括号。您当前正在做的是将
count
作为
shape
传入,然后将
count
作为数据类型再次传入。它无法识别
count
表示的数据类型,因此会出现错误

newRatios = np.zeros((count,count))