There are two problems with this code,

You are applying self.fc_out layer two times in your forward function,

x1 = F.relu(self.fc_out(x1))
x1 = self.fc_out(x1)


If after correcting the above, the error comes up it might be because of number of input neurons in self.fc_out. To fix it, comment out self.fc_out layer totally from init and forward, pass images through the model and print the resultant shape, the last dim should be your number of input_neurons, put it back and now you have fixed your self.fc_out.