enable any dict and namespace in hparams (#1847)

This commit is contained in:
William Falcon
2020-05-15 15:08:16 -04:00
committed by GitHub
parent e95e1d71c7
commit b84b02400a
+4 -3
View File
@@ -344,10 +344,11 @@ class TrainerIOMixin(ABC):
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':
if isinstance(model.hparams, dict):
checkpoint['hparams_type'] = 'dict'
checkpoint['hparams'] = model.hparams
elif checkpoint['hparams_type'] == 'Namespace':
elif isinstance(model.hparams, Namespace):
checkpoint['hparams_type'] = 'Namespace'
checkpoint['hparams'] = vars(model.hparams)
else:
raise ValueError(