a better way to write this since it flatten the output of conv layer is
shape = torch.prod(torch.tensor(x.shape[1:])).item()
x = x.view(-1, shape)
Also
should be
self.fc1 = nn.Linear(Number of Flattened Features from last layer , 1024,...)
Further, read this post for better understanding.