Skip to content

Commit

Permalink
[checkpoint logic] Fix bug which doesn't account for NoneType for `mo…
Browse files Browse the repository at this point in the history
…del.hparams` (#1817)

The intention of the code is to output a warning message when `hparams`
is null or not set. Instead the code now fatals when
`model.hparams = None`. Prevent that.
  • Loading branch information
ashwinb authored and williamFalcon committed May 13, 2020
1 parent 82aaf41 commit db46840
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pytorch_lightning/trainer/training_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ def dump_checkpoint(self):
if self.use_amp and self.use_native_amp:
checkpoint['native_amp_scaling_state'] = self.scaler.state_dict()

if hasattr(model, "hparams"):
if hasattr(model, "hparams") and model.hparams is not None:
parsing.clean_namespace(model.hparams)
checkpoint['hparams_type'] = model.hparams.__class__.__name__
if checkpoint['hparams_type'] == 'dict':
Expand Down

0 comments on commit db46840

Please sign in to comment.