(self)
| 65 | self.eta_max = optimizer.lr.numpy()[0] |
| 66 | |
| 67 | def get_lr(self) -> Tensor: |
| 68 | lr = self.eta_min + 0.5 * (self.eta_max - self.eta_min) * (1 + math.cos((self.epoch_counter.numpy()[0]/self.T_max) * math.pi)) |
| 69 | return Tensor([lr], device=self.optimizer.device, dtype=self.optimizer.lr.dtype) |
| 70 | |
| 71 | class OneCycleLR(LR_Scheduler): |
| 72 | def __init__(self, optimizer: Optimizer, max_lr: float, div_factor: float, final_div_factor: float, total_steps: int, pct_start: float, |