Could you check the shapes of x and self.weights.t() inside the forward method?
I guess the one of these tensors is not a 2-dimensional tensor:
w = torch.randn(10, 10)
x = torch.randn(10, 10)

y = torch.mm(x, w) # works
y = torch.mm(x[0], w) # shape mismatch
> RuntimeError: self must be a matrix