The output shape of some layers depends on the input shape (e.g. for convolutions) and the output shape might be unknown before passing the real inputs.
For the sake of debugging you could add print statements into your forward method and check the shape of each activation. Alternatively, you could also manually calculate the output shapes, if the input shapes are known in advance, but the print approach is often simpler.