import numpy as np

a = np.array([[0, 1, 2, 3],
             [4, 5, 6, 7],
             [8, 9, 10, 11]])
print(a)

'''
[[ 0  1  2  3]
 [ 4  5  6  7]
 [ 8  9 10 11]]
'''

print(a.reshape(2, 6)) # 形状変換

'''
[[ 0  1  2  3  4  5]
 [ 6  7  8  9 10 11]]
'''

b = np.arange(24).reshape(2, 3, 4)
# np.arange(24) は 0 以上 24 未満の整数を 1 次元 array として生成
print(b) # 3 次元 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]]]
'''

print(b.reshape(2, 3, 2, -1)) # 形状変換

'''
[[[[ 0  1]
   [ 2  3]]

  [[ 4  5]
   [ 6  7]]

  [[ 8  9]
   [10 11]]]


 [[[12 13]
   [14 15]]

  [[16 17]
   [18 19]]

  [[20 21]
   [22 23]]]]
'''

print(b.reshape(-1)) # 1 次元 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]
'''