Here’s the traceback 7 of my error. The actual error reads RuntimeError: size mismatch, m1: [20 x 1], m2: [5 x 512].
I’ve been able to track partially the source of the errors to the following:
The mismatch comes from the dot product
(batchsize x input_size) * (seq_length x 4*hidden_dim)
which is the dot product of the data batch with c0/h0 in the forward step. (I think 4*hidden_dim corresponds  to each one of the weight matrices for each one of the soft logical gates i, f, o, and g).
As far as I can tell, I’m passing a properly shaped tensor to LSTM (seq_length, num_samples, input_size) or (5, 20, 1) and c0/h0 seem to be ok also like so:
h0 = Variable(torch.zeros([1, 20, 128]), requires_grad=False)
Help? I’ve been thinking about this way too long I need a drink. Peace.