(self)
Resets optimizer state.
Resets optimizer state.
Resets optimizer state .
def reset_state(self):
        """Resets optimizer state."""
        for p in self.w.parameters():
            if 'state' in self.state[p]:
                self.state[p]['step'] = 0
            if 'exp_avg' in self.state[p]:
                self.state[p]['exp_avg'] = torch.zeros_like(p.data)
            if 'exp_avg_sq' in self.state[p]:
                self.state[p]['exp_avg_sq'] = torch.zeros_like(p.data)
            if self.amsgrad and 'max_exp_avg_sq' in self.state[p]:
                self.state[p]['max_exp_avg_sq'] = torch.zeros_like(p.data)
def reset_state ( self ) : for p in self . w . parameters ( ) : if 'state' in self . state [ p ] : self . state [ p ] [ 'step' ] = 0 if 'exp_avg' in self . state [ p ] : self . state [ p ] [ 'exp_avg' ] = torch . zeros_like ( p . data ) if 'exp_avg_sq' in self . state [ p ] : self . state [ p ] [ 'exp_avg_sq' ] = torch . zeros_like ( p . data ) if self . amsgrad and 'max_exp_avg_sq' in self . state [ p ] : self . state [ p ] [ 'max_exp_avg_sq' ] = torch . zeros_like ( p . data )