The shape mismatch is caused by the nn.Linear layer called self.l3 in your model, so you could check, if the input activation is properly reshaped and if so adapt the in_features of self.l3 to match the features of the input.