Skip to content

Commit

Permalink
Revert "Simplify the conditionals used for learning rate calculation …
Browse files Browse the repository at this point in the history
…for `ConstantLR` learning rate scheduler (#109785)"

This reverts commit 83283b4.

Reverted #109785 on behalf of https://github.com/PaliC due to causing macos errors as per https://hud.pytorch.org/pytorch/pytorch/commit/83283b4f0dc2032a31f9a80c7aa40e3e552ec944 ([comment](#109785 (comment)))
  • Loading branch information
pytorchmergebot committed Sep 29, 2023
1 parent b253fc9 commit c2c7c40
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions torch/optim/lr_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,10 +489,12 @@ def get_lr(self):
if self.last_epoch == 0:
return [group['lr'] * self.factor for group in self.optimizer.param_groups]

if self.last_epoch != self.total_iters:
if (self.last_epoch > self.total_iters or
(self.last_epoch != self.total_iters)):
return [group['lr'] for group in self.optimizer.param_groups]

return [group['lr'] * (1.0 / self.factor) for group in self.optimizer.param_groups]
if (self.last_epoch == self.total_iters):
return [group['lr'] * (1.0 / self.factor) for group in self.optimizer.param_groups]

def _get_closed_form_lr(self):
return [base_lr * (self.factor + (self.last_epoch >= self.total_iters) * (1 - self.factor))
Expand Down

0 comments on commit c2c7c40

Please sign in to comment.