Your reasoning is fine.
The error is thrown, because you are not flattening out before passing it to the linear layer.
Add this line of code before self.fc1 is called: out = out.view(out.size(0), -1) and it should work.