The error is raised since the number of features in out doesn’t match the in_features in self.fc.
Add a print statement as print(out.shape) after the view operation and before passing it to self.fc.
This would give you the expected number of features for self.fc, which you could then fix.
Also, your forward method doesn’t return the logit, so you might want to add the return statement.