(self)
Zeroes out all gradients.
Zeroes out all gradients.
Zeroes out all gradients .
def zero_grad(self):
        """Zeroes out all gradients."""
        for p in self.w.parameters():
            if p.grad is not None:
                p.grad.detach_()
                p.grad.zero_()
def zero_grad ( self ) : for p in self . w . parameters ( ) : if p . grad is not None : p . grad . detach_ ( ) p . grad . zero_ ( )