Skip to content

Commit

Permalink
Modify ModelCheckpoint to never save a checkpoint automatically when …
Browse files Browse the repository at this point in the history
…evaluating

Without this, ModelCheckpoint might delete the very checkpoint being evaluated. Furthermore, the model will not change during evaluation anyway.
  • Loading branch information
EliaCereda committed Nov 18, 2020
1 parent 307c89a commit 9e59e6d
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions pytorch_lightning/callbacks/model_checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ def save_checkpoint(self, trainer, pl_module):
or self.period < 1 # no models are saved
or (epoch + 1) % self.period # skip epoch
or trainer.running_sanity_check # don't save anything during sanity check
or trainer.evaluating # don't save anything during evaluation: might delete the checkpoint being evaluated
or self.last_global_step_saved == global_step # already saved at the last step
):
return
Expand Down

0 comments on commit 9e59e6d

Please sign in to comment.