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.]])