今天发现一个操作符
import torch
a = torch.tensor([[1,2],
[2,3],
[5,6]])
b = torch.tensor([[2,1],
[8,5],
[3,2]])
c = a*b
d = a @ b.t() ## [3,2] @ [2,3]
print('*',c)
print('@',d)
结果如下
import torch
# Define matrices
A = torch.randn(3, 4)
B = torch.randn(4, 5)
# Matrix multiplication
C = torch.matmul(A, B)
print(C)
结果如下