In def Forward function you can add print(x.shape) in any place you want to check the size in. For example if you want to see output after  x=x.reshape(x.shape[0], -1), you can add print(x.shape) in the next line (before  x = F.relu(self.fc1(x)))