From 15c477e9fc9a604fc62cf29fcf649357f7534c32 Mon Sep 17 00:00:00 2001 From: prajakta0111 <58019417+prajakta0111@users.noreply.github.com> Date: Sun, 28 Feb 2021 09:52:26 -0500 Subject: [PATCH] document exceptions for metrics/regression (#6202) Co-authored-by: Akihiro Nitta Co-authored-by: Prajakta Phadke Co-authored-by: Rohit Gupta --- .../metrics/regression/explained_variance.py | 4 ++++ pytorch_lightning/metrics/regression/psnr.py | 4 ++++ pytorch_lightning/metrics/regression/r2score.py | 8 +++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/pytorch_lightning/metrics/regression/explained_variance.py b/pytorch_lightning/metrics/regression/explained_variance.py index 467ac72cc3..fc033fcd16 100644 --- a/pytorch_lightning/metrics/regression/explained_variance.py +++ b/pytorch_lightning/metrics/regression/explained_variance.py @@ -59,6 +59,10 @@ class ExplainedVariance(Metric): process_group: Specify the process group on which synchronization is called. default: None (which selects the entire world) + Raises: + ValueError: + If ``multioutput`` is not one of ``"raw_values"``, ``"uniform_average"`` or ``"variance_weighted"``. + Example: >>> from pytorch_lightning.metrics import ExplainedVariance diff --git a/pytorch_lightning/metrics/regression/psnr.py b/pytorch_lightning/metrics/regression/psnr.py index b07941f010..8a38bf515e 100644 --- a/pytorch_lightning/metrics/regression/psnr.py +++ b/pytorch_lightning/metrics/regression/psnr.py @@ -51,6 +51,10 @@ class PSNR(Metric): process_group: Specify the process group on which synchronization is called. default: None (which selects the entire world) + Raises: + ValueError: + If ``dim`` is not ``None`` and ``data_range`` is not given. + Example: >>> from pytorch_lightning.metrics import PSNR diff --git a/pytorch_lightning/metrics/regression/r2score.py b/pytorch_lightning/metrics/regression/r2score.py index 77f6c1363a..40d9d24711 100644 --- a/pytorch_lightning/metrics/regression/r2score.py +++ b/pytorch_lightning/metrics/regression/r2score.py @@ -66,6 +66,12 @@ class R2Score(Metric): process_group: Specify the process group on which synchronization is called. default: None (which selects the entire world) + Raises: + ValueError: + If ``adjusted`` parameter is not an integer larger or equal to 0. + ValueError: + If ``multioutput`` is not one of ``"raw_values"``, ``"uniform_average"`` or ``"variance_weighted"``. + Example: >>> from pytorch_lightning.metrics import R2Score @@ -102,7 +108,7 @@ class R2Score(Metric): self.num_outputs = num_outputs if adjusted < 0 or not isinstance(adjusted, int): - raise ValueError('`adjusted` parameter should be an integer larger or' ' equal to 0.') + raise ValueError('`adjusted` parameter should be an integer larger or equal to 0.') self.adjusted = adjusted allowed_multioutput = ('raw_values', 'uniform_average', 'variance_weighted')