How can I save and restore the trained model when I call fit() at pytorch_lightning every time? #9551
-
Hi, everyone! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Beta Was this translation helpful? Give feedback.
For loading the model, are you looking to load just the weights? If so, take a look at LightningModule.load_from_checkpoint: https://pytorch-lightning.readthedocs.io/en/latest/common/weights_loading.html#checkpoint-loading
Otherwise, if you want to load the whole training state (for example, including the optimizer states), take a look here: https://pytorch-lightning.readthedocs.io/en/latest/common/weights_loading.html#restoring-training-state
For saving, take a look at the ModelCheckpoint callback: https://pytorch-lightning.readthedocs.io/en/latest/common/weights_loading.html#automatic-saving