RuntimeError: size mismatch, m1: [5 x 10], m2: [5 x 32] at /pytorch/aten/src/TH/generic/THTensorMath.cpp

Hi Masilive!

The short answer is that you have the dimensions of your input
swapped. You would want something like, for example, “m1: [10 x 5]”.

Pytorch will interpret state as a batch of 5 samples, each of which
is a vector of 10 values.

But the first layer of your Sequential is a Linear that is expecting an
input vector that consists of only 5 values.

Remember, pytorch models always work on batches of samples (even
if the batch size is 1). So the first dimension of state is, in fact, your
batch size.

How to fix this depends on what you want your state tensor to mean.
Is it supposed to be a batch of 5 length-10 vectors (as it is being treated
now), or is it supposed to be a batch of 10 length-5 vectors? Or
something else?

Good luck.

K. Frank