3 回答

TA贡献1876条经验 获得超5个赞
你可以改造成(350, 277, 3):
>>> a = np.array([(x,x,x) for x in range(10)])
>>> a.reshape((2,5,3))
array([[[0, 0, 0],
[1, 1, 1],
[2, 2, 2],
[3, 3, 3],
[4, 4, 4]],
[[5, 5, 5],
[6, 6, 6],
[7, 7, 7],
[8, 8, 8],
[9, 9, 9]]])
从技术上讲,结果不会是一个 350x277 的 3 元组的 2D 数组,而是一个 350x277x3 的 3D 数组,但您array_of_tuple的实际“元组数组”也不是一个 2D 数组。

TA贡献1895条经验 获得超3个赞
reshaped_array=np.reshape(array_of_tuple,(350,-1))
reshaped_array.shape
给出 (350, 831)
由于覆盖数组的整个元素的列号和行号不匹配,您收到错误
350*831= 290850 where as
350*277=96950
因此 numpy 不知道如何处理数组的附加元素,您可以尝试减小数组的原始大小以减少元素数量。如果您不想删除元素,则
reshape(350,277,3)
是一种选择
添加回答
举报