(self)
| 80 | super().__init__(optimizer, last_epoch) |
| 81 | |
| 82 | def get_lr(self): |
| 83 | step_num = self.last_epoch |
| 84 | |
| 85 | if step_num > self.total_steps: |
| 86 | return self.min_lr |
| 87 | |
| 88 | if step_num <= self.pct_start * self.total_steps: |
| 89 | pct = step_num / (self.pct_start * self.total_steps) |
| 90 | return [initial + (maximum - initial) * pct |
| 91 | for initial, maximum in zip(self.initial_lr, self.max_lr)] |
| 92 | else: |
| 93 | pct = (step_num - self.pct_start * self.total_steps) / ((1 - self.pct_start) * self.total_steps) |
| 94 | |
| 95 | if self.anneal_strategy == 'cos': |
| 96 | return [minimum + (maximum - minimum) * (1 + math.cos(math.pi * pct)) / 2 |
| 97 | for minimum, maximum in zip(self.min_lr, self.max_lr)] |
| 98 | else: |
| 99 | return [maximum - (maximum - minimum) * pct |
| 100 | for minimum, maximum in zip(self.min_lr, self.max_lr)] |
| 101 | |
| 102 | class PolynomialLR(_LRScheduler): |
| 103 | def __init__(self, optimizer, total_iters, power=1.0, last_epoch=-1): |
nothing calls this directly
no outgoing calls
no test coverage detected