lightning/docs/Trainer/Checkpointing.md

23 lines
476 B
Markdown
Raw Normal View History

Lightning can automate saving and loading checkpoints.
---
### Model saving
2019-06-28 21:42:32 +00:00
To enable checkpointing, define the checkpoint callback and give it to the trainer.
``` {.python}
from pytorch_lightning.utils.pt_callbacks import ModelCheckpoint
2019-06-28 21:42:32 +00:00
checkpoint_callback = ModelCheckpoint(
filepath='/path/to/store/weights.ckpt',
2019-06-28 21:42:32 +00:00
save_best_only=True,
verbose=True,
2019-06-28 21:42:32 +00:00
monitor='val_loss',
mode='min'
)
2019-06-28 21:42:32 +00:00
trainer = Trainer(checkpoint_callback=checkpoint_callback)
```