You are using model.eval() which is used to evaluate your model. When using model.eval() Pytorch will not calculate gradients for your network. As the error clearly tells you params.grad is None. Therefore you have no gradients at that parameter and can’t continue with  abs() and sum(). I also don’t believe that even without the model.eval that you will get gradients without a Feedforward step