Improved docs for pytorch_lightning.core (continued) (#1483)

* improved docs for core

update links


add references to hooks lifecycle


wip


continue with __init__.py


improve docs for memory.py


improve docs for saving.py


simpler links


fix formatting

* move hooks lifecycle to top of file

* fix doctest import problem

* add missing hook in lifecycle
This commit is contained in:
Adrian Wälchli
2020-04-16 12:04:55 -04:00
committed by GitHub
parent 6e1d72d98a
commit 2ab2f7d08d
5 changed files with 320 additions and 270 deletions
+19 -7
View File
@@ -10,16 +10,21 @@ class ModelIO(object):
def on_load_checkpoint(self, checkpoint: Dict[str, Any]) -> None:
"""
Do something with the checkpoint
Gives model a chance to load something before state_dict is restored
:param checkpoint:
:return:
Do something with the checkpoint.
Gives model a chance to load something before ``state_dict`` is restored.
Args:
checkpoint: A dictionary with variables from the checkpoint.
"""
def on_save_checkpoint(self, checkpoint: Dict[str, Any]) -> None:
"""
Give the model a chance to add something to the checkpoint.
state_dict is already there
``state_dict`` is already there.
Args:
checkpoint: A dictionary in which you can save variables to save in a checkpoint.
Contents need to be pickleable.
"""
# -------------------------
@@ -27,12 +32,19 @@ class ModelIO(object):
# -------------------------
def on_hpc_save(self, checkpoint: Dict[str, Any]) -> None:
"""
Hook to do whatever you need right before Slurm manager saves the model
Hook to do whatever you need right before Slurm manager saves the model.
Args:
checkpoint: A dictionary in which you can save variables to save in a checkpoint.
Contents need to be pickleable.
"""
def on_hpc_load(self, checkpoint: Dict[str, Any]) -> None:
"""
Hook to do whatever you need right before Slurm manager loads the model
Hook to do whatever you need right before Slurm manager loads the model.
Args:
checkpoint: A dictionary with variables from the checkpoint.
"""