Unverified Commit f49a3453 authored by wasupandceacar's avatar wasupandceacar Committed by GitHub
Browse files

Fix `ReduceLROnPlateau` object has no attribute 'get_last_lr' (#23944)

* Fix 'ReduceLROnPlateau' object has no attribute 'get_last_lr'

* fix style
parent c62b01d0
...@@ -850,6 +850,9 @@ def _get_learning_rate(self): ...@@ -850,6 +850,9 @@ def _get_learning_rate(self):
last_lr = 0 last_lr = 0
else: else:
raise raise
else:
if isinstance(self.lr_scheduler, torch.optim.lr_scheduler.ReduceLROnPlateau):
last_lr = self.optimizer.param_groups[0]["lr"]
else: else:
last_lr = self.lr_scheduler.get_last_lr()[0] last_lr = self.lr_scheduler.get_last_lr()[0]
if torch.is_tensor(last_lr): if torch.is_tensor(last_lr):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment