It looks like self.fc1 is expecting a different number of features.
How about adding this line just before x = F.relu(self.fc1(x))
print(x.size(1), self.fc1.weight.size(1))

That should print the number of flat features in x and the number of features that self.fc1 expects.