1 運用numpy中的,arrang,reshape,生成陣列形狀為[2,3,4]的陣列
>>> import numpy as np
>>> x=np.arange(24).reshape(2,3,4)
>>> x
array([[[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11]],
[[12, 13, 14, 15],
[16, 17, 18, 19],
[20, 21, 22, 23]]])
>>> x.transpose((0,2,1))
array([[[ 0, 4, 8],
[ 1, 5, 9],
[ 2, 6, 10],
[ 3, 7, 11]],
[[12, 16, 20],
[13, 17, 21],
[14, 18, 22],
[15, 19, 23]]])
>>> x.transpose((2,1,0))
array([[[ 0, 12],
[ 4, 16],
[ 8, 20]],
[[ 1, 13],
[ 5, 17],
[ 9, 21]],
[[ 2, 14],
[ 6, 18],
[10, 22]],
[[ 3, 15],
[ 7, 19],
[11, 23]]])
uj5u.com熱心網友回復:
問題在哪呢?轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/31570.html
標籤:其他開發語言
