Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>
  • Loading branch information
kepler and Borda authored May 13, 2020
1 parent c5abd85 commit 53416fb
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions pytorch_lightning/trainer/training_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,10 @@ def dump_checkpoint(self, weights_only: bool = False):
}

if not weights_only:
if self.checkpoint_callback is not None and self.checkpoint_callback is not False:
if self.checkpoint_callback:
checkpoint['checkpoint_callback_best'] = self.checkpoint_callback.best

if self.early_stop_callback is not None and self.checkpoint_callback is not False:
if self.early_stop_callback:
checkpoint['early_stop_callback_wait'] = self.early_stop_callback.wait
checkpoint['early_stop_callback_patience'] = self.early_stop_callback.patience

Expand Down Expand Up @@ -386,9 +386,8 @@ def restore_training_state(self, checkpoint):
"""
if 'optimizer_states' not in checkpoint or 'lr_schedulers' not in checkpoint:
raise KeyError(
f'Trying to restore training state but checkpoint contains only the model. '
f'This is probably due to `ModelCheckpoint.save_weights_only` being set to '
f'True.'
'Trying to restore training state but checkpoint contains only the model.'
' This is probably due to `ModelCheckpoint.save_weights_only` being set to `True`.'
)

if self.checkpoint_callback is not None and self.checkpoint_callback is not False:
Expand Down

0 comments on commit 53416fb

Please sign in to comment.