MCPcopy Create free account
hub / github.com/geekcomputers/Python / get_lr

Method get_lr

ML/src/python/neuralforge/optim/schedulers.py:82–100  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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
102class PolynomialLR(_LRScheduler):
103 def __init__(self, optimizer, total_iters, power=1.0, last_epoch=-1):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected