Backward compatibility for checkpoint loading (#1132)

* check if hparams_type exists in checkpoint dictionary for backward compatibility

* concisely maintain backward compatibility for hparams type

* Bug fix in checkpoint loading (#1132)
This commit is contained in:
Abhinav Moudgil
2020-03-17 18:45:36 -04:00
committed by GitHub
parent 1a73fa0b03
commit 73a911890b
2 changed files with 2 additions and 1 deletions
+1
View File
@@ -29,6 +29,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
### Fixed
- Fixed bug related to type cheking of `ReduceLROnPlateau` lr schedulers([#1114](https://github.com/PyTorchLightning/pytorch-lightning/issues/1114))
- Fixed a bug to ensure lightning checkpoints to be backward compatible ([#1132](https://github.com/PyTorchLightning/pytorch-lightning/pull/1132))
## [0.7.1] - 2020-03-07
+1 -1
View File
@@ -1396,7 +1396,7 @@ class LightningModule(ABC, GradInformation, ModelIO, ModelHooks):
if cls_takes_hparams:
if ckpt_hparams is not None:
is_namespace = checkpoint.get('hparams_type') == 'namespace'
is_namespace = checkpoint.get('hparams_type', 'namespace') == 'namespace'
hparams = Namespace(**ckpt_hparams) if is_namespace else ckpt_hparams
else:
warnings.warn(