numpy之矩阵属性03

import numpy as np
print (np.arange(15))
a = np.arange(20).reshape(2,5,2)
a

[ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14]
array([[[ 0, 1],
[ 2, 3],
[ 4, 5],
[ 6, 7],
[ 8, 9]],

[[10, 11],
[12, 13],
[14, 15],
[16, 17],
[18, 19]]])

# 矩阵形状
a.shape

(2, 5, 2)

# 矩阵维度
a.ndim

3

# 矩阵元素个数
a.size

20

# 矩阵元素类型
a.dtype.name

‘int64’

np.zeros((3,4))

array([[0., 0., 0., 0.],
[0., 0., 0., 0.],
[0., 0., 0., 0.]])

猜你喜欢

转载自blog.csdn.net/hechaojie_com/article/details/82798758
今日推荐