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
|
2019-07-27 01:37:06 +00:00
|
|
|
Gives model a chance to load something before state_dict is restored
|
2019-03-31 01:45:16 +00:00
|
|
|
:param checkpoint:
|
|
|
|
:return:
|
|
|
|
"""
|
2019-07-27 01:37:06 +00:00
|
|
|
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
|
|
|
"""
|
2019-07-27 01:37:06 +00:00
|
|
|
pass
|
2019-03-31 01:45:16 +00:00
|
|
|
|
2019-07-02 13:36:33 +00:00
|
|
|
# -------------------------
|
|
|
|
# OPTIONAL HOOKS
|
|
|
|
# -------------------------
|
2019-07-27 02:04:27 +00:00
|
|
|
def on_hpc_save(self, checkpoint):
|
2019-07-02 13:35:15 +00:00
|
|
|
"""
|
|
|
|
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):
|
2019-07-02 13:35:15 +00:00
|
|
|
"""
|
|
|
|
Hook to do whatever you need right before Slurm manager loads the model
|
|
|
|
:return:
|
|
|
|
"""
|
|
|
|
pass
|