lightning/pytorch_lightning/root_module/model_saving.py

35 lines
890 B
Python
Raw Normal View History

2019-03-31 01:45:16 +00:00
class ModelIO(object):
2019-07-27 02:04:27 +00:00
def on_load_checkpoint(self, checkpoint):
2019-03-31 01:45:16 +00:00
"""
Do something with the checkpoint
Gives model a chance to load something before state_dict is restored
2019-03-31 01:45:16 +00:00
:param checkpoint:
:return:
"""
pass
2019-03-31 01:45:16 +00:00
2019-07-27 02:04:27 +00:00
def on_save_checkpoint(self, checkpoint):
2019-03-31 01:45:16 +00:00
"""
2019-07-27 02:04:27 +00:00
Give the model a chance to add something to the checkpoint.
state_dict is already there
2019-03-31 01:45:16 +00:00
"""
pass
2019-03-31 01:45:16 +00:00
# -------------------------
# OPTIONAL HOOKS
# -------------------------
2019-07-27 02:04:27 +00:00
def on_hpc_save(self, checkpoint):
"""
Hook to do whatever you need right before Slurm manager saves the model
:return:
"""
pass
2019-07-27 02:04:27 +00:00
def on_hpc_load(self, checkpoint):
"""
Hook to do whatever you need right before Slurm manager loads the model
:return:
"""
pass