The linear layer is raising this error, as the number of input features from the activation doesn’t match the in_features from the layer.
Check the shape of lstm_out and make sure it’s [batch_size, *, in_features].
PS: I would also be careful with using torch.squeeze without specifying the dim argument, as it could also remove the batch dimension, if you are working with a single sample, which is usually not desired.