Pycharm is a useful python debugger that allows you to set the measurement of breakpoints and views of your tensor.
To make debugging easier, don't push things forward like this
output1 = self.Batch1(self.ReLu1(self.Lin1(input)))
Instead of this
h1 = self.ReLu1(self.Lin1(input)) h2 = self.Batch1(h1)
For stacktrace, Pytorch also provides Pythonic stacktrack errors. I believe that before
RuntimeError: matrices expected, got 3D, 2D tensors at /py/conda-bld/pytorch_1493681908901/work/torch/lib/TH/generic/THTensorMath.c:1232
There are some python stacktrace errors that point directly to your code. To simplify debugging, as I said, do not fold forward.
You use Pycharm to create a breakpoint before . In the debugger observer, then use Variable(torch.rand(dim1, dim2)) to check the forward input, output measurement, and if the measurement is incorrect. Comparison with input dimension. Call input.size() in the debugger observer.
For example, self.ReLu1(self.Lin1(Variable(torch.rand(10, 20)))).size() . If the reading text is displayed (error), then the input size is incorrect. Otherwise, it shows the size of the output.

- Read the docs
In Pytorch Docs , it defines the size of the I / O. It also has snip code example.
>>> rnn = nn.RNN(10, 20, 2) >>> input = Variable(torch.randn(5, 3, 10)) >>> h0 = Variable(torch.randn(2, 3, 20)) >>> output, hn = rnn(input, h0)
You can use snip code in PyCharm Debugger to examine input size, output a certain level of your interest (RNN, Linear, BatchNorm1d).