2019-06-28 21:14:18 +00:00
|
|
|
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.
|
2019-06-28 21:14:18 +00:00
|
|
|
|
|
|
|
``` {.python}
|
|
|
|
from pytorch_lightning.utils.pt_callbacks import ModelCheckpoint
|
|
|
|
|
2019-06-28 21:42:32 +00:00
|
|
|
checkpoint_callback = ModelCheckpoint(
|
2019-06-28 21:14:18 +00:00
|
|
|
filepath='/path/to/store/weights.ckpt',
|
2019-06-28 21:42:32 +00:00
|
|
|
save_best_only=True,
|
2019-06-28 21:14:18 +00:00
|
|
|
verbose=True,
|
2019-06-28 21:42:32 +00:00
|
|
|
monitor='val_loss',
|
|
|
|
mode='min'
|
2019-06-28 21:14:18 +00:00
|
|
|
)
|
2019-06-28 21:42:32 +00:00
|
|
|
|
|
|
|
trainer = Trainer(checkpoint_callback=checkpoint_callback)
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|