I don’t know how you’ve initialized the model and in particular which shapes you’ve used to initialize the layers, but the shape mismatch is most likely raised by a linear layer.
Print the shape of the input activation to each layer and make sure its feature dimension matches the expected in_features of the layer.