This error might be raised, if the number of input features of an activation doesn’t match the expected in_features of a linear layer.
Try to print the shape of the flattened activation before feeding it into a linear layer and make sure the features match.