0
点赞
收藏
分享

微信扫一扫

size()和shape()详解

开源分享 2022-03-11 阅读 69
python

size()shape()Numpy中才有的函数。
size
用来计算数组和矩阵中所有元素的个数

a = np.array([[1, 2, 3], [4, 5, 6]])
np.size(a)    # 返回值为6
np.size(a,1)    # 返回值为3

shape
用来计算矩阵每维的大小

np.shape(a)    # 返回值为(2, 3)
举报

相关推荐

0 条评论