Save a epoch=x.pt (TorchScript) file in the same directory as epoch=x.cpkt.
In more detail
Besides saving the weights, I also want to save a TorchScript version of the model when the on_checkpoint is called (e.g. a lower val_loss has been achieved). However, I cannot extract where this checkpoint is being saved.
How do I set file_path to match weights_save_path/lightning_logs/version_x/checkpoints/epoch=2.ckpt? trainer._weights_save_path only contains the directory your code is called from (when not changed), but I need the full path, including version_x and epoch no.
Question
How do I get the location of epoch=2.ckpt in a Callback?
I already looked through trainer.__dict__ and trainer.logger.__dict__. While I could find current_epoch and trainer._weights_save_path, log_dir did not show up. How did you know about this variable?
An extra question: Automatically delete the .pt file
PyTorch Lightning automatically only keeps the best epoch (or multiple epochs if you set save_top_k).
How do I enable the same logic for my TorchScript .pt file? I want to delete .pt files when the matching .ckpt file is deleted.