ndim, size, shape的区别
import numpy as np c=np.array([1,2,3]) d=np.array([[1,2,3],[4,5,6],[7,8,9]]) e=np.array([[[1,2,3],[4,5,6],[7,8,9]]]) c.ndim # 1 d.ndim # 2 e.ndim # 3 c.shape # (3,) d.shape # (3, 3) e.shape # (1, 3, 3) c.size # 3 d.size # 9 e.size # 9
ndim描述的是维度
shape描述的是矩阵的形状
size描述的是元素的个数