How to show the learning rate during training

Hi Alberto, yes it is possible to include learning rate in the evaluation logs!

Fortunately, the log() method of the Trainer class is one of the methods that you can “subclass” to inject custom behaviour: Trainer

So, all you have to do is create your own Trainer subclass and override the log() method like so:

class MyTrainer(Trainer):
    def log(self, logs: Dict[str, float]) -> None:
        logs["learning_rate"] = self._get_learning_rate()
        super().log(logs)

trainer = MyTrainer(...)
trainer.train()

You should now see the learning rate in the eval logs.

Hope that helps, let me know if any questions.

Cheers
Heiko

3 Likes