Solved by Nikronic in post #2 
              
              
                Hi, 
You should not use .data on the output of your model. It only returns the matrix of you tensor not the other atttributes like grad_fn. 

Use like this: 
out = self.model(x)


By the way, you only need .data for initializing the weights and biases, not in training and eval methods.