diff --git a/src/pytorch_lightning/CHANGELOG.md b/src/pytorch_lightning/CHANGELOG.md index b20547fb25696..12fa38817fea8 100644 --- a/src/pytorch_lightning/CHANGELOG.md +++ b/src/pytorch_lightning/CHANGELOG.md @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). + +## [unreleased] - 2022-MM-DD + +### Changed + +- Moved the warning about saving nn.Module in `save_hyperparameters()` to before the deepcopy ([#15132](https://github.com/Lightning-AI/lightning/pull/15132)) + + ## [1.8.0] - 2022-MM-DD diff --git a/src/pytorch_lightning/utilities/parsing.py b/src/pytorch_lightning/utilities/parsing.py index 87d43791e5fe5..eed889716f88f 100644 --- a/src/pytorch_lightning/utilities/parsing.py +++ b/src/pytorch_lightning/utilities/parsing.py @@ -256,8 +256,6 @@ def save_hyperparameters( # `hparams` are expected here obj._set_hparams(hp) - # make deep copy so there is not other runtime changes reflected - obj._hparams_initial = copy.deepcopy(obj._hparams) for k, v in obj._hparams.items(): if isinstance(v, nn.Module): @@ -266,6 +264,9 @@ def save_hyperparameters( f" It is recommended to ignore them using `self.save_hyperparameters(ignore=[{k!r}])`." ) + # make a deep copy so there are no other runtime changes reflected + obj._hparams_initial = copy.deepcopy(obj._hparams) + class AttributeDict(Dict): """Extended dictionary accessible with dot notation.