a = torch.arange(6).reshape(3, 2) b = torch.tensor([[2, 4], [1, 6], [3, 5]]) print(a, '\n', b) print(torch.einsum("ik,ik->i", a, b)) print(torch.einsum("ik,jk->i", a, b)) # tensor([[0, 1], # [2, 3], # [4, 5]]) # tensor([[2, 4], # [1, 6], # [3, 5]]) # tensor([ 4, 20, 37]) # tensor([15, 57, 99])
理解 einsum
于 2024-11-26 20:26:33 首次发布