np.reshape()用法
作用:
修改数组矩阵结构
代码
import numpy as np
three = np.arange(24).reshape(2,3,4)
print('three:',three)
three_reshape = np.reshape(three,(4,3,2))
print('three_reshape:',three_reshape)
效果:
three: [[[ 0 1 2 3]
[ 4 5 6 7]
[ 8 9 10 11]]
[[12 13 14 15]
[16 17 18 19]
[20 21 22 23]]]
three_reshape: [[[ 0 1]
[ 2 3]
[ 4 5]]
[[ 6 7]
[ 8 9]
[10 11]]
[[12 13]
[14 15]
[16 17]]
[[18 19]
[20 21]
[22 23]]]
Process finished with exit code 0