【发布时间】:2017-09-18 17:40:18
【问题描述】:
我在 Numpy 中有以下 3D 数组:
a = np.array([[[1,2],[3,4]], [[5,6],[7,8]], [[9,10],[11,12]],[[13,14],[15,16]]])
当我写作时
b = np.reshape(a, [4,4])
二维结果数组看起来像
[[ 1 2 3 4]
[ 5 6 7 8]
[ 9 10 11 12]
[13 14 15 16]]
但是,我希望它是这种形状:
[[ 1 2 5 6]
[ 3 4 7 8]
[ 9 10 13 14]
[11 12 15 16]]
如何在 Python/Numpy 中有效地做到这一点?
【问题讨论】:
标签: python arrays numpy reshape