3
我要重塑以下數組:重塑一個數組的Python/numpy的
>>> test
array([ 11., 12., 13., 14., 21., 22., 23., 24., 31., 32., 33.,
34., 41., 42., 43., 44.])
,以獲得:
>>> test2
array([[ 11., 12., 21., 22.],
[ 13., 14., 23., 24.],
[ 31., 32., 41., 42.],
[ 33., 34., 43., 44.]])
我有試過 「重塑」 像
>>> test.reshape(4,4)
array([[ 11., 12., 13., 14.],
[ 21., 22., 23., 24.],
[ 31., 32., 33., 34.],
[ 41., 42., 43., 44.]])
And
>>> test.reshape(2,2,2,2)
array([[[[ 11., 12.],
[ 13., 14.]],
[[ 25., 26.],
[ 27., 28.]]],
[[[ 39., 31.],
[ 32., 33.]],
[[ 41., 44.],
[ 45., 46.]]]])
我試過不同的組合,但沒有任何作品。
感謝