Skip to content

Commit

Permalink
Cosine schedule logging LR fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bghira committed Oct 31, 2023
1 parent f534ebf commit c41db23
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion helpers/training/custom_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,4 +235,17 @@ def __exit__(self, type, value, traceback):
param_group['lr'] = math.floor(lr * 1e9) / 1e9
self.print_lr(self.verbose, i, lr, epoch)

self._last_lr = [group['lr'] for group in self.optimizer.param_groups]
self._last_lr = [group['lr'] for group in self.optimizer.param_groups]

def print_lr(self, is_verbose, group, lr, epoch=None):
"""Display the current learning rate.
"""
if is_verbose:
if epoch is None:
print('Adjusting learning rate'
' of group {} to {:.8e}.'.format(group, lr))
else:
epoch_str = ("%.2f" if isinstance(epoch, float) else
"%.5d") % epoch
print('Epoch {}: adjusting learning rate'
' of group {} to {:.8e}.'.format(epoch_str, group, lr))

0 comments on commit c41db23

Please sign in to comment.