python shape reshape简单用法
- shape
import numpy as np
# shape
a = np.array([[1,2,3,4,5,6,7,8]])
print(a)
b = a.shape[0] # 查看行
print(b)
c = a.shape[1] # 查看列
print(c)
result:
2.reshape
a = np.array([1,2,3,4,5,6,7,8])
c = a.reshape((4,2)) # 4行2列
d = a.reshape((8,1)) # 8行1列
print(a)
print(c)
print(d)
result: