This error is most likely raised due to a tensor shape mismatch inside your model, e.g. in a linear layer. Print the activation shapes inside the forward method and make sure the feature size matches the expected in_features from the linear layers.