- Yet another exploration of einsum in pytorch.
- Also demonstrates the notebook cell facility to display results using the amazing Zed editor.
Benefits:
- The same notation should (mostly) work across libraries.
torch.einsum("ij->ji", x)
torch.einsum("ij->", x)
torch.einsum("ij->j", x)
torch.einsum("ij->i", x)
v = torch.rand((1,3))
torch.einsum("ij,kj->ik", x, v)
torch.einsum("ij,kj->ik", x, x) # %% 2x2: 2x3 X 3x2
torch.einsum("i,i->", x[0], x[0])
torch.einsum("ij,ij->", x, x)
torch.einsum("ij,ij->ij", x, x)
a = torch.rand((3))
b = torch.rand((5))
a
b
torch.einsum("i,j->ij", a,b)
a = torch.rand((3,2,5))
b = torch.rand((3,5,3))
a
b
torch.einsum("ijk,ikl->ijl", a, b)
x = torch.rand((3,3))
x
torch.einsum("ii->i", x)
torch.einsum("ii->", x)