I have an M x N matrix and would like to multiply each M x 1 column by an L x M matrix with learnable elements, yielding N L-dimensional vectors. Is there a simple way to do this, something like * but for matrix multiplication? Bonus: Iād ultimately like to return an (N.L) stacked vector where each column multiplication is stacked on top of each other. Any help to do this simply (and such that gradients can pass through these operators) would be amazing
It sounds like a normal matrix multiplication?
M, N, L = 3, 4, 5
input = torch.rand(M, N).float()
weight = nn.Parameter(torch.rand(L, M).float(), True)
result = torch.mm(weight, input).t()
print(result.shape)
1 Like