From c3efe7a2022d2e0ad6ec3f973e144e5c99ce75e8 Mon Sep 17 00:00:00 2001 From: Teddy Koker Date: Thu, 10 Dec 2020 11:24:01 -0500 Subject: [PATCH 1/5] add back *deprecated* metric utility functions to functional --- .../metrics/functional/__init__.py | 2 ++ .../metrics/functional/deprecated.py | 21 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 pytorch_lightning/metrics/functional/deprecated.py diff --git a/pytorch_lightning/metrics/functional/__init__.py b/pytorch_lightning/metrics/functional/__init__.py index e13242e40b0ac..f3ae68242aa2f 100644 --- a/pytorch_lightning/metrics/functional/__init__.py +++ b/pytorch_lightning/metrics/functional/__init__.py @@ -38,3 +38,5 @@ from pytorch_lightning.metrics.functional.roc import roc from pytorch_lightning.metrics.functional.self_supervised import embedding_similarity from pytorch_lightning.metrics.functional.ssim import ssim + +from pytorch_lightning.metrics.functional.deprecated import to_categorical, to_onehot diff --git a/pytorch_lightning/metrics/functional/deprecated.py b/pytorch_lightning/metrics/functional/deprecated.py new file mode 100644 index 0000000000000..6049b4177efc4 --- /dev/null +++ b/pytorch_lightning/metrics/functional/deprecated.py @@ -0,0 +1,21 @@ +from pytorch_lightning.metrics.utils import to_categorical as new_to_categorical +from pytorch_lightning.metrics.utils import to_onehot as new_to_onehot + +import warnings + + +# TODO: remove in 1.1.1 +def to_onehot(*args, **kwargs): + warnings.warn( + "pytorch_lightning.metrics.functional.to_onehot is deprecated please use pytorch_lightning.metrics.utils.to_onehot", + DeprecationWarning, + ) + return new_to_onehot(*args, **kwargs) + +# TODO: remove in 1.1.1 +def to_categorical(*args, **kwargs): + warnings.warn( + "pytorch_lightning.metrics.functional.to_categorical is deprecated please use pytorch_lightning.metrics.utils.to_categorical", + DeprecationWarning, + ) + return new_to_categorical(*args, **kwargs) From 95624fd936bdc7a3650da82d61341e3e7f0a9263 Mon Sep 17 00:00:00 2001 From: Teddy Koker Date: Thu, 10 Dec 2020 11:32:06 -0500 Subject: [PATCH 2/5] pep --- pytorch_lightning/metrics/functional/deprecated.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pytorch_lightning/metrics/functional/deprecated.py b/pytorch_lightning/metrics/functional/deprecated.py index 6049b4177efc4..d4601441ddb8e 100644 --- a/pytorch_lightning/metrics/functional/deprecated.py +++ b/pytorch_lightning/metrics/functional/deprecated.py @@ -12,6 +12,7 @@ def to_onehot(*args, **kwargs): ) return new_to_onehot(*args, **kwargs) + # TODO: remove in 1.1.1 def to_categorical(*args, **kwargs): warnings.warn( From 1a9fa268f68a3d6e47ef6c8757f4e0d28ffc2196 Mon Sep 17 00:00:00 2001 From: Teddy Koker Date: Thu, 10 Dec 2020 11:34:33 -0500 Subject: [PATCH 3/5] pep --- pytorch_lightning/metrics/functional/deprecated.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pytorch_lightning/metrics/functional/deprecated.py b/pytorch_lightning/metrics/functional/deprecated.py index d4601441ddb8e..444fe1645570c 100644 --- a/pytorch_lightning/metrics/functional/deprecated.py +++ b/pytorch_lightning/metrics/functional/deprecated.py @@ -7,7 +7,10 @@ # TODO: remove in 1.1.1 def to_onehot(*args, **kwargs): warnings.warn( - "pytorch_lightning.metrics.functional.to_onehot is deprecated please use pytorch_lightning.metrics.utils.to_onehot", + ( + "pytorch_lightning.metrics.functional.to_onehot is deprecated, " + "please use pytorch_lightning.metrics.utils.to_onehot" + ), DeprecationWarning, ) return new_to_onehot(*args, **kwargs) @@ -16,7 +19,10 @@ def to_onehot(*args, **kwargs): # TODO: remove in 1.1.1 def to_categorical(*args, **kwargs): warnings.warn( - "pytorch_lightning.metrics.functional.to_categorical is deprecated please use pytorch_lightning.metrics.utils.to_categorical", + ( + "pytorch_lightning.metrics.functional.to_categorical is deprecated, " + "please use pytorch_lightning.metrics.utils.to_categorical" + ), DeprecationWarning, ) return new_to_categorical(*args, **kwargs) From 51fbf038daaf6bd6bc972bf3e05b09a13a20a2a6 Mon Sep 17 00:00:00 2001 From: Teddy Koker Date: Thu, 10 Dec 2020 12:01:12 -0500 Subject: [PATCH 4/5] suggestions --- pytorch_lightning/metrics/functional/deprecated.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pytorch_lightning/metrics/functional/deprecated.py b/pytorch_lightning/metrics/functional/deprecated.py index 444fe1645570c..40c4308452184 100644 --- a/pytorch_lightning/metrics/functional/deprecated.py +++ b/pytorch_lightning/metrics/functional/deprecated.py @@ -1,10 +1,10 @@ -from pytorch_lightning.metrics.utils import to_categorical as new_to_categorical -from pytorch_lightning.metrics.utils import to_onehot as new_to_onehot +from pytorch_lightning.metrics.utils import to_categorical as __to_categorical +from pytorch_lightning.metrics.utils import to_onehot as __to_onehot import warnings -# TODO: remove in 1.1.1 +# TODO: remove in 1.2 def to_onehot(*args, **kwargs): warnings.warn( ( @@ -13,10 +13,10 @@ def to_onehot(*args, **kwargs): ), DeprecationWarning, ) - return new_to_onehot(*args, **kwargs) + return __to_onehot(*args, **kwargs) -# TODO: remove in 1.1.1 +# TODO: remove in 1.2 def to_categorical(*args, **kwargs): warnings.warn( ( @@ -25,4 +25,4 @@ def to_categorical(*args, **kwargs): ), DeprecationWarning, ) - return new_to_categorical(*args, **kwargs) + return __to_categorical(*args, **kwargs) From 5e99b450758759eacdeb157776a8e90fe742bb83 Mon Sep 17 00:00:00 2001 From: Jirka Borovec Date: Thu, 10 Dec 2020 19:50:42 +0100 Subject: [PATCH 5/5] move --- CHANGELOG.md | 4 +-- .../metrics/functional/__init__.py | 3 +- .../metrics/functional/deprecated.py | 28 ------------------- 3 files changed, 3 insertions(+), 32 deletions(-) delete mode 100644 pytorch_lightning/metrics/functional/deprecated.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 951aee6049b7a..2b1ee04401d4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,9 +44,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). ### Changed -- Removed `multiclass_roc` and `multiclass_precision_recall_curve`, use `roc` and `precision_recall_curve` instead ([#4549](https://github.com/PyTorchLightning/pytorch-lightning/pull/4549)) - Tuner algorithms will be skipped if `fast_dev_run=True` ([#3903](https://github.com/PyTorchLightning/pytorch-lightning/pull/3903)) -- WandbLogger does not force wandb `reinit` arg to True anymore and creates a run only when needed ([#4648](https://github.com/PyTorchLightning/pytorch-lightning/pull/4648)) +- `WandbLogger` does not force wandb `reinit` arg to True anymore and creates a run only when needed ([#4648](https://github.com/PyTorchLightning/pytorch-lightning/pull/4648)) - Changed `automatic_optimization` to be a model attribute ([#4602](https://github.com/PyTorchLightning/pytorch-lightning/pull/4602)) - Changed `Simple Profiler` report to order by percentage time spent + num calls ([#4880](https://github.com/PyTorchLightning/pytorch-lightning/pull/4880)) - Simplify optimization Logic ([#4984](https://github.com/PyTorchLightning/pytorch-lightning/pull/4984)) @@ -64,6 +63,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). ### Removed - Removed `reorder` parameter of the `auc` metric ([#5004](https://github.com/PyTorchLightning/pytorch-lightning/pull/5004)) +- Removed `multiclass_roc` and `multiclass_precision_recall_curve`, use `roc` and `precision_recall_curve` instead ([#4549](https://github.com/PyTorchLightning/pytorch-lightning/pull/4549)) ### Fixed diff --git a/pytorch_lightning/metrics/functional/__init__.py b/pytorch_lightning/metrics/functional/__init__.py index f3ae68242aa2f..86f919d0fb3f4 100644 --- a/pytorch_lightning/metrics/functional/__init__.py +++ b/pytorch_lightning/metrics/functional/__init__.py @@ -38,5 +38,4 @@ from pytorch_lightning.metrics.functional.roc import roc from pytorch_lightning.metrics.functional.self_supervised import embedding_similarity from pytorch_lightning.metrics.functional.ssim import ssim - -from pytorch_lightning.metrics.functional.deprecated import to_categorical, to_onehot +from pytorch_lightning.metrics.utils import to_categorical, to_onehot diff --git a/pytorch_lightning/metrics/functional/deprecated.py b/pytorch_lightning/metrics/functional/deprecated.py deleted file mode 100644 index 40c4308452184..0000000000000 --- a/pytorch_lightning/metrics/functional/deprecated.py +++ /dev/null @@ -1,28 +0,0 @@ -from pytorch_lightning.metrics.utils import to_categorical as __to_categorical -from pytorch_lightning.metrics.utils import to_onehot as __to_onehot - -import warnings - - -# TODO: remove in 1.2 -def to_onehot(*args, **kwargs): - warnings.warn( - ( - "pytorch_lightning.metrics.functional.to_onehot is deprecated, " - "please use pytorch_lightning.metrics.utils.to_onehot" - ), - DeprecationWarning, - ) - return __to_onehot(*args, **kwargs) - - -# TODO: remove in 1.2 -def to_categorical(*args, **kwargs): - warnings.warn( - ( - "pytorch_lightning.metrics.functional.to_categorical is deprecated, " - "please use pytorch_lightning.metrics.utils.to_categorical" - ), - DeprecationWarning, - ) - return __to_categorical(*args, **kwargs)