A = np.arange(36).reshape(6,6)
B = A.reshape(-1,3,2,3)
C = B.transpose(0,2,1,3)
I have a matrix A
, which looks like
[[ 0 1 2 3 4 5]
[ 6 7 8 9 10 11]
[12 13 14 15 16 17]
[18 19 20 21 22 23]
[24 25 26 27 28 29]
[30 31 32 33 34 35]]
and have transformed it into C
, which looks like
[[[[ 0 1 2]
[ 6 7 8]
[12 13 14]]
[[ 3 4 5]
[ 9 10 11]
[15 16 17]]]
[[[18 19 20]
[24 25 26]
[30 31 32]]
[[21 22 23]
[27 28 29]
[33 34 35]]]]
How would I transform C back into A? I have tried following this guide https://stackoverflow.com/a/32034565/5131031, however, I was not successful.