コード例 #1
0
 def __init__(self, tensor, inner_scheduler_cfg, last_epoch=-1):
     mock_optimizer = torch.optim.SGD([torch.zeros(1)], lr=tensor.item())
     self.tensor = tensor
     scheduler_cls = get_scheduler_cls(inner_scheduler_cfg.pop("type"))
     self.inner_scheduler = scheduler_cls(mock_optimizer,
                                          **inner_scheduler_cfg)
     super(TensorScheduler, self).__init__(mock_optimizer, last_epoch)
コード例 #2
0
ファイル: torch_utils.py プロジェクト: scape1989/aw_nas
def init_scheduler(optimizer, cfg):
    if cfg and optimizer is not None:
        cfg = {k:v for k, v in six.iteritems(cfg)}
        sch_cls = get_scheduler_cls(cfg.pop("type"))
        return sch_cls(optimizer, **cfg)
    return None