Your view to flatten to output of conv3 is wrong.
x has the shape [20, 64, 28, 28], while you are using x.view(-1, 64*4*4), which creates an activation of [980, 1024] thus changing the batch size.
Use x = x.view(x.size(0), -1) instead and set the in_features of fc1 to 64*28*28.
PS: I’ve edited your post for better readability.
You can post code snippets by wrapping them into three backticks ```