Python Numpy 数组:序列太大
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17688094/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Numpy array: sequence too large
提问by Matt
I have an array of size 11
called 'wavelength' and a larger array of size n
called 'MN'. And 'model' is an m
by n
array.
我有一个11
称为“波长”的大小数组和一个n
称为“MN”的更大大小的数组。'model' 是一个m
byn
数组。
I'm doing this:
我这样做:
for i in xrange(10+len(wavelength)-2):
y=np.empty(model[MN][i],float)
and getting this as an error:
并将其作为错误:
File "test_prog.py", line 658, in <module>
y=np.empty(model[MN][i],float)
ValueError: sequence too large; must be smaller than 32
I'm not sure what to do about that. I've looked elsewhere online but I can't find anything of obvious substance.
我不知道该怎么办。我在网上其他地方看过,但找不到任何明显的实质内容。
采纳答案by HYRY
sequence too large
error means that you are creating a multidimension array that has a dimension larger than 32. For example: np.empty([1]*33)
will raise this error.
sequence too large
错误意味着您正在创建一个维度大于 32 的多维数组。例如:np.empty([1]*33)
将引发此错误。
Are you sure you want to create >32 dimension array? If you want to create an empty array the same shape as model[MN][i]
, you should use: empty_like()
您确定要创建 > 32 维数组吗?如果要创建与 形状相同的空数组model[MN][i]
,则应使用:empty_like()