3 回答

TA貢獻(xiàn)1876條經(jīng)驗(yàn) 獲得超5個(gè)贊
你可以改造成(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]]])
從技術(shù)上講,結(jié)果不會(huì)是一個(gè) 350x277 的 3 元組的 2D 數(shù)組,而是一個(gè) 350x277x3 的 3D 數(shù)組,但您array_of_tuple的實(shí)際“元組數(shù)組”也不是一個(gè) 2D 數(shù)組。

TA貢獻(xiàn)1895條經(jīng)驗(yàn) 獲得超3個(gè)贊
reshaped_array=np.reshape(array_of_tuple,(350,-1))
reshaped_array.shape
給出 (350, 831)
由于覆蓋數(shù)組的整個(gè)元素的列號(hào)和行號(hào)不匹配,您收到錯(cuò)誤
350*831= 290850 where as
350*277=96950
因此 numpy 不知道如何處理數(shù)組的附加元素,您可以嘗試減小數(shù)組的原始大小以減少元素?cái)?shù)量。如果您不想刪除元素,則
reshape(350,277,3)
是一種選擇
添加回答
舉報(bào)