Most likely the shape mismatch is raised by the first linear layer after you are flattening the activation via:
x = x.view(x.size(0), -1)

If your last activation output has a shape of [1, 512, 7, 7], the number of input features of the following linear layer would have to be [512*7*7 = 25088].
Feel free to post the model definition in case you get stuck.