(self)
Set weight decay and step optimizer.
Set weight decay and step optimizer.
Set weight decay and step optimizer .
def step(self) -> None:
        "Set weight decay and step optimizer."
        # weight decay outside of optimizer step (AdamW)
        if self.true_wd:
            for lr, wd, pg1, pg2 in zip(self._lr, self._wd,
                                        self.opt.param_groups[::2],
                                        self.opt.param_groups[1::2]):
                for p in pg1['params']:
                    p.data.mul_(1 - wd * lr)
                if self.bn_wd:
                    for p in pg2['params']:
                        p.data.mul_(1 - wd * lr)
            self.set_val('weight_decay', listify(0, self._wd))
        self.opt.step()
def step ( self ) -> None : # weight decay outside of optimizer step (AdamW) if self . true_wd : for lr , wd , pg1 , pg2 in zip ( self . _lr , self . _wd , self . opt . param_groups [ : : 2 ] , self . opt . param_groups [ 1 : : 2 ] ) : for p in pg1 [ 'params' ] : p . data . mul_ ( 1 - wd * lr ) if self . bn_wd : for p in pg2 [ 'params' ] : p . data . mul_ ( 1 - wd * lr ) self . set_val ( 'weight_decay' , listify ( 0 , self . _wd ) ) self . opt . step ( )