对于一维普通数组取shape 时只有第一项有值 举例 (4,)
对于二维普通数组取shape 时才会有完整的第二项值 举例 (4,1)
https://blog.csdn.net/zenghaitao0128/article/details/78300770
什么是秩
https://www.zhihu.com/question/21605094
自己实验
import numpy as np
X=np.array([[-0.60116],
[-0.94159],
[-0.74565],
[0.89583]])
w = [0]
b=1
z= np.matmul(X,w) + b
print(X.shape)
W = np.zeros(X.shape[1])
print("W=",W)
print("W.TYPE=",type(W),"w.shape=",W.shape)
W2 = np.zeros(X.shape[0])
print("W2=",W2)
print("W2.TYPE=",type(W2),"w2.shape=",W2.shape)
W3=np.array([[0, 0, 0, 0]])
print("W3=",W3)
print("W3.TYPE=",type(W3),"w3.shape=",W3.shape)
W4 = np.zeros(4)
print("W4=",W4)
print("W4.TYPE=",type(W4),"w4.shape=",W4.shape)
W5 = np.array([[0,0,0,0]])
print("W5=",W5)
print("W5.TYPE=",type(W5),"w5.shape=",W5.shape)
W6 = np.array([0,0,0,0])
print("W6=",W6)
print("W6.TYPE=",type(W6),"w6.shape=",W6.shape)
(4, 1) W= [0.] W.TYPE= <class 'numpy.ndarray'> w.shape= (1,) W2= [0. 0. 0. 0.] W2.TYPE= <class 'numpy.ndarray'> w2.shape= (4,) W3= [[0 0 0 0]] W3.TYPE= <class 'numpy.ndarray'> w3.shape= (1, 4) W4= [0. 0. 0. 0.] W4.TYPE= <class 'numpy.ndarray'> w4.shape= (4,) W5= [[0 0 0 0]] W5.TYPE= <class 'numpy.ndarray'> w5.shape= (1, 4) W6= [0 0 0 0] W6.TYPE= <class 'numpy.ndarray'> w6.shape= (4,)