小程序
tr=torch.Tensor([[100000,200000],[1,2]])
tr1=torch.Tensor([1,2])
tr2=torch.Tensor([1,2])
print(tr1+tr2)
print(tr/2)
print(torch.sum(tr*np.reshape(tr1,(-1,1)),dim=0))
w=nn.Softmax()
print(torch.matmul(tr,tr1.T))
print(w(torch.matmul(tr,tr1.T)))
print(tr*np.reshape(w(torch.matmul(tr,tr1.T)),(-1,1)))
w=nn.Softmax(dim=0)
w1=torch.Tensor([0,0,0])
w2=torch.Tensor([[1,1,1],[2,2,2],[3,3,3]])
print(torch.sum(w2*w(torch.zeros((3,1))),dim=0))

浙公网安备 33010602011771号