因为需要生成一个和现有矩阵大小相等的矩阵,故查找了相关资料
>>> import numpy as np
>>> a= np.array([[1,2],[3,4]])
>>> b= np.zeros(a.size)
>>> b
array([0., 0., 0., 0.])
>>> b= np.zeros(a.shape)
>>> b
array([[0., 0.],
[0., 0.]])
因为需要生成一个和现有矩阵大小相等的矩阵,故查找了相关资料
>>> import numpy as np
>>> a= np.array([[1,2],[3,4]])
>>> b= np.zeros(a.size)
>>> b
array([0., 0., 0., 0.])
>>> b= np.zeros(a.shape)
>>> b
array([[0., 0.],
[0., 0.]])