"...git@developer.sourcefind.cn:chenpangpang/transformers.git" did not exist on "19f0b7dd02c7ea7cbf86cc87fe00667470266722"
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
......@@ -851,7 +851,10 @@ def _get_learning_rate(self):
else:
raise
else:
last_lr = self.lr_scheduler.get_last_lr()[0]
if isinstance(self.lr_scheduler, torch.optim.lr_scheduler.ReduceLROnPlateau):
last_lr = self.optimizer.param_groups[0]["lr"]
else:
last_lr = self.lr_scheduler.get_last_lr()[0]
if torch.is_tensor(last_lr):
last_lr = last_lr.item()
return 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