def zero_grad(params): """ Clear gradients as they accumulate on successive backward calls Args: params: an iterator over tensors i.e., updating the Weights and biases Returns: Nothing """ for par in params: if not(par.grad is None): par.grad.data.zero_()
zero grad
Remark
clear the gradient after one epoch