You can print the shape of the flattened x tensor after the view operation and set the in_features of self.fc1 to this value:
x = x.view(x.size(0), -1)
print(x.shape)

as suggested before or alternatively, you could manually calculate the output shapes of the activations using the shape formulas for the corresponding layers in the docs.