Also ModelCheckpoint
has a method called format_checkpoint_name
that is actually called when saving checkpoints and does the overall formatting. The callback itself can be accessed by trainer.checkpoint_callback
As an example, if you want to save the weights of your model before training, you can add the following hook to your LightningModule
:
def on_train_start(self):
self.trainer.save_checkpoint(self.trainer.checkpoint_callback.format_checkpoint_name(dict(epoch=0, step=0)))