You can simply calculate a convolution layer’s spatial dims using the standard formula
(W - F + 2P)/S + 1 where W can be width/height, F is filter size, P is the padding and S is the stride.
This helps you in choosing the appropriate dimensions for the following nn.Linear layer.
You can also get the output shape by simply printing the torch.Tensor.size() inside the forward method.