MCPcopy
hub / github.com/appvision-ai/fast-bert / get_lr

Method get_lr

fast_bert/learner_cls.py:1060–1070  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1058 super(LinearLR, self).__init__(optimizer, last_epoch)
1059
1060 def get_lr(self):
1061 # In earlier Pytorch versions last_epoch starts at -1, while in recent versions
1062 # it starts at 0. We need to adjust the math a bit to handle this. See
1063 # discussion at: https://github.com/davidtvs/pytorch-lr-finder/pull/42
1064 if PYTORCH_VERSION < version.parse("1.1.0"):
1065 curr_iter = self.last_epoch + 1
1066 r = curr_iter / (self.num_iter - 1)
1067 else:
1068 r = self.last_epoch / (self.num_iter - 1)
1069
1070 return [base_lr + r * (self.end_lr - base_lr) for base_lr in self.base_lrs]
1071
1072
1073class ExponentialLR(_LRScheduler):

Callers 4

lr_findMethod · 0.95
fitMethod · 0.45
fitMethod · 0.45
fitMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected