python的@ 除了用在装饰器上,还可以用在矩阵乘法操作。
效果大概等同于mul。
code举例:
import torch
ea = [[1, 2, 3],
[3, 2, 1]]
eb = [[1, 2],
[2, 1],
[1, 1]]
ea = torch.tensor(ea)
eb = torch.tensor(eb)
print(ea.shape)
print(eb.shape)
ec = ea @ eb
print(ec)
print(ec.shape)
""" output:
torch.Size([2, 3])
torch.Size([3, 2])
tensor([[8, 7],
[8, 9]])
torch.Size([2, 2])
"""