matmul 相当于利用广播机制的点积
true_w = torch.tensor([2,-3.4])
X = torch.normal(0,1,(2,len(true_w)))
y = torch.matmul(X,true_w)
print(X)
print(true_w)
print(y)
tensor([[-0.8593, -1.6781], [ 0.9634, -0.7398]])
tensor([ 2.0000, -3.4000])
tensor([3.9871, 4.4420])
torch.dot(X[0,],true_w)
tensor(3.9871)
和y[0]一样