Skip to content

Commit

Permalink
if learning rate is a tensor, get item (float) (#18861)
Browse files Browse the repository at this point in the history
  • Loading branch information
kmckiern authored Sep 2, 2022
1 parent 142e12a commit 9b3eb81
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/transformers/trainer_pt_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,8 @@ def _get_learning_rate(self):
if version.parse(version.parse(torch.__version__).base_version) >= version.parse("1.4")
else self.lr_scheduler.get_lr()[0]
)
if torch.is_tensor(last_lr):
last_lr = last_lr.item()
return last_lr


Expand Down

0 comments on commit 9b3eb81

Please sign in to comment.