I assume the error might be raised in this line of code:
x = self.linear1(x)

If that’s the case, the number of features in the flattened activation doesn’t match the specified in_features in the self.linear1 layer and you would have to adapt the layer.
PS: you can post code snippets by wrapping them into three backticks ```, which makes debugging easier