[checkpoint logic] Fix bug which doesn't account for NoneType for `model.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.
This commit is contained in:
Ashwin Bharambe 2020-05-13 14:14:11 -07:00 committed by GitHub
parent 12138ced7c
commit 0e71705a0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -342,7 +342,7 @@ class TrainerIOMixin(ABC):
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':