From 1676087437590c4cbb398b743b5ea47ea4558d14 Mon Sep 17 00:00:00 2001 From: "hailin.wang" Date: Wed, 1 Sep 2021 19:31:52 +0800 Subject: [PATCH 1/2] Add docstring to HyperparametersMixin --- pytorch_lightning/core/mixins/hparams_mixin.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pytorch_lightning/core/mixins/hparams_mixin.py b/pytorch_lightning/core/mixins/hparams_mixin.py index 72129f22f54bb..1aac499794370 100644 --- a/pytorch_lightning/core/mixins/hparams_mixin.py +++ b/pytorch_lightning/core/mixins/hparams_mixin.py @@ -126,12 +126,26 @@ def _to_hparams_dict(hp: Union[MutableMapping, Namespace, str]): @property def hparams(self) -> Union[AttributeDict, dict, Namespace]: + """ + The collection of hyperparameters saved with :meth:`save_hyperparameters`. It is mutable by the user. + For the frozen set of initial hyperparameters, use :attr:`hparams_initial`. + + Returns: + Union[AttributeDict, dict, Namespace]: mutable hyperparameters dicionary + """ if not hasattr(self, "_hparams"): self._hparams = AttributeDict() return self._hparams @property def hparams_initial(self) -> AttributeDict: + """ + The collection of hyperparameters saved with :meth:`save_hyperparameters`. These contents are read-only. + Manual updates to the saved hyperparameters can instead be performed through :attr:`hparams`. + + Returns: + AttributeDict: immutable initial hyperparameters + """ if not hasattr(self, "_hparams_initial"): return AttributeDict() # prevent any change From f253514b2a338c0cc81a902fe36baaee1470f5ee Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 1 Sep 2021 11:42:59 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pytorch_lightning/core/mixins/hparams_mixin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pytorch_lightning/core/mixins/hparams_mixin.py b/pytorch_lightning/core/mixins/hparams_mixin.py index 1aac499794370..c864de23d3cf2 100644 --- a/pytorch_lightning/core/mixins/hparams_mixin.py +++ b/pytorch_lightning/core/mixins/hparams_mixin.py @@ -129,7 +129,7 @@ def hparams(self) -> Union[AttributeDict, dict, Namespace]: """ The collection of hyperparameters saved with :meth:`save_hyperparameters`. It is mutable by the user. For the frozen set of initial hyperparameters, use :attr:`hparams_initial`. - + Returns: Union[AttributeDict, dict, Namespace]: mutable hyperparameters dicionary """ @@ -142,7 +142,7 @@ def hparams_initial(self) -> AttributeDict: """ The collection of hyperparameters saved with :meth:`save_hyperparameters`. These contents are read-only. Manual updates to the saved hyperparameters can instead be performed through :attr:`hparams`. - + Returns: AttributeDict: immutable initial hyperparameters """