代码
import numpy as np
a=np.arange(8).reshape(2,4)
print(a)
print(a.shape)
b=a.reshape(8)
print(b)
print(b.shape)
运行结果
[[0 1 2 3]
[4 5 6 7]]
(2, 4)
[0 1 2 3 4 5 6 7]
(8,)
import numpy as np
a=np.arange(8).reshape(2,4)
print(a)
print(a.shape)
b=a.reshape(8)
print(b)
print(b.shape)
[[0 1 2 3]
[4 5 6 7]]
(2, 4)
[0 1 2 3 4 5 6 7]
(8,)