From 1789b1722d374169a5c1080ab117393405d08bca Mon Sep 17 00:00:00 2001 From: Tanmoy Date: Thu, 5 May 2022 15:46:39 +0530 Subject: [PATCH] Removed Deprecated compute_on_step from audio (#1007) * Removed Deprecated compute_on_step from audio * Update CHANGELOG.md * import fix --- CHANGELOG.md | 3 +++ torchmetrics/audio/pesq.py | 10 ++-------- torchmetrics/audio/pit.py | 10 ++-------- torchmetrics/audio/sdr.py | 16 ++-------------- torchmetrics/audio/snr.py | 19 +++---------------- torchmetrics/audio/stoi.py | 10 ++-------- 6 files changed, 14 insertions(+), 54 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 044b2a72cba..fff4578b101 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,6 +55,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Removed deprecated `compute_on_step` argument in aggregation ([#990](https://github.com/PyTorchLightning/metrics/pull/990)) +- Removed deprecated `compute_on_step` argument in audio ([#1007](https://github.com/PyTorchLightning/metrics/pull/1007)) + + ### Fixed - Fixed multi device aggregation in `PearsonCorrCoef` ([#998](https://github.com/PyTorchLightning/metrics/pull/998)) diff --git a/torchmetrics/audio/pesq.py b/torchmetrics/audio/pesq.py index 97098206193..93b282ca8eb 100644 --- a/torchmetrics/audio/pesq.py +++ b/torchmetrics/audio/pesq.py @@ -11,7 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from typing import Any, Dict, Optional +from typing import Any, Dict from torch import Tensor, tensor @@ -42,11 +42,6 @@ class PerceptualEvaluationSpeechQuality(Metric): fs: sampling frequency, should be 16000 or 8000 (Hz) mode: ``'wb'`` (wide-band) or ``'nb'`` (narrow-band) keep_same_device: whether to move the pesq value to the device of preds - compute_on_step: - Forward only calls ``update()`` and returns None if this is set to False. - - .. deprecated:: v0.8 - Argument has no use anymore and will be removed v0.9. kwargs: Additional keyword arguments, see :ref:`Metric kwargs` for more info. @@ -84,10 +79,9 @@ def __init__( self, fs: int, mode: str, - compute_on_step: Optional[bool] = None, **kwargs: Dict[str, Any], ) -> None: - super().__init__(compute_on_step=compute_on_step, **kwargs) + super().__init__(**kwargs) if not _PESQ_AVAILABLE: raise ModuleNotFoundError( "PerceptualEvaluationSpeechQuality metric requires that `pesq` is installed." diff --git a/torchmetrics/audio/pit.py b/torchmetrics/audio/pit.py index f001d8b0211..b3b5b80690b 100644 --- a/torchmetrics/audio/pit.py +++ b/torchmetrics/audio/pit.py @@ -11,7 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from typing import Any, Callable, Dict, Optional +from typing import Any, Callable, Dict from torch import Tensor, tensor @@ -37,11 +37,6 @@ class PermutationInvariantTraining(Metric): eval_func: the function to find the best permutation, can be 'min' or 'max', i.e. the smaller the better or the larger the better. - compute_on_step: - Forward only calls ``update()`` and returns None if this is set to False. - - .. deprecated:: v0.8 - Argument has no use anymore and will be removed v0.9. kwargs: Additional keyword arguments for either the ``metric_func`` or distributed communication, see :ref:`Metric kwargs` for more info. @@ -74,7 +69,6 @@ def __init__( self, metric_func: Callable, eval_func: str = "max", - compute_on_step: Optional[bool] = None, **kwargs: Dict[str, Any], ) -> None: base_kwargs: Dict[str, Any] = { @@ -82,7 +76,7 @@ def __init__( "process_group": kwargs.pop("process_group", None), "dist_sync_fn": kwargs.pop("dist_sync_fn", None), } - super().__init__(compute_on_step=compute_on_step, **base_kwargs) + super().__init__(**base_kwargs) self.metric_func = metric_func self.eval_func = eval_func self.kwargs = kwargs diff --git a/torchmetrics/audio/sdr.py b/torchmetrics/audio/sdr.py index ee5fb85c21b..0fed368bf73 100644 --- a/torchmetrics/audio/sdr.py +++ b/torchmetrics/audio/sdr.py @@ -45,11 +45,6 @@ class SignalDistortionRatio(Metric): If provided, this small value is added to the diagonal coefficients of the system metrics when solving for the filter coefficients. This can help stabilize the metric in the case where some reference signals may sometimes be zero - compute_on_step: - Forward only calls ``update()`` and returns None if this is set to False. - - .. deprecated:: v0.8 - Argument has no use anymore and will be removed v0.9. kwargs: Additional keyword arguments, see :ref:`Metric kwargs` for more info. @@ -89,10 +84,9 @@ def __init__( filter_length: int = 512, zero_mean: bool = False, load_diag: Optional[float] = None, - compute_on_step: Optional[bool] = None, **kwargs: Dict[str, Any], ) -> None: - super().__init__(compute_on_step=compute_on_step, **kwargs) + super().__init__(**kwargs) self.use_cg_iter = use_cg_iter self.filter_length = filter_length @@ -132,11 +126,6 @@ class ScaleInvariantSignalDistortionRatio(Metric): Args: zero_mean: if to zero mean target and preds or not - compute_on_step: - Forward only calls ``update()`` and returns None if this is set to False. - - .. deprecated:: v0.8 - Argument has no use anymore and will be removed v0.9. kwargs: Additional keyword arguments, see :ref:`Metric kwargs` for more info. @@ -169,10 +158,9 @@ class ScaleInvariantSignalDistortionRatio(Metric): def __init__( self, zero_mean: bool = False, - compute_on_step: Optional[bool] = None, **kwargs: Dict[str, Any], ) -> None: - super().__init__(compute_on_step=compute_on_step, **kwargs) + super().__init__(**kwargs) self.zero_mean = zero_mean self.add_state("sum_si_sdr", default=tensor(0.0), dist_reduce_fx="sum") diff --git a/torchmetrics/audio/snr.py b/torchmetrics/audio/snr.py index b170a9cd3b7..02d8d3323f8 100644 --- a/torchmetrics/audio/snr.py +++ b/torchmetrics/audio/snr.py @@ -11,7 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from typing import Any, Dict, Optional +from typing import Any, Dict from torch import Tensor, tensor @@ -36,11 +36,6 @@ class SignalNoiseRatio(Metric): Args: zero_mean: if to zero mean target and preds or not - compute_on_step: - Forward only calls ``update()`` and returns None if this is set to False. - - .. deprecated:: v0.8 - Argument has no use anymore and will be removed v0.9. kwargs: Additional keyword arguments, see :ref:`Metric kwargs` for more info. @@ -73,10 +68,9 @@ class SignalNoiseRatio(Metric): def __init__( self, zero_mean: bool = False, - compute_on_step: Optional[bool] = None, **kwargs: Dict[str, Any], ) -> None: - super().__init__(compute_on_step=compute_on_step, **kwargs) + super().__init__(**kwargs) self.zero_mean = zero_mean self.add_state("sum_snr", default=tensor(0.0), dist_reduce_fx="sum") @@ -108,12 +102,6 @@ class ScaleInvariantSignalNoiseRatio(Metric): - ``target``: ``shape [...,time]`` Args: - compute_on_step: - Forward only calls ``update()`` and returns None if this is set to False. - - .. deprecated:: v0.8 - Argument has no use anymore and will be removed v0.9. - kwargs: Additional keyword arguments, see :ref:`Metric kwargs` for more info. Raises: @@ -145,10 +133,9 @@ class ScaleInvariantSignalNoiseRatio(Metric): def __init__( self, - compute_on_step: Optional[bool] = None, **kwargs: Dict[str, Any], ) -> None: - super().__init__(compute_on_step=compute_on_step, **kwargs) + super().__init__(**kwargs) self.add_state("sum_si_snr", default=tensor(0.0), dist_reduce_fx="sum") self.add_state("total", default=tensor(0), dist_reduce_fx="sum") diff --git a/torchmetrics/audio/stoi.py b/torchmetrics/audio/stoi.py index 66211269304..8d122aeed50 100644 --- a/torchmetrics/audio/stoi.py +++ b/torchmetrics/audio/stoi.py @@ -11,7 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from typing import Any, Dict, Optional +from typing import Any, Dict from torch import Tensor, tensor @@ -44,11 +44,6 @@ class ShortTimeObjectiveIntelligibility(Metric): Args: fs: sampling frequency (Hz) extended: whether to use the extended STOI described in [4] - compute_on_step: - Forward only calls ``update()`` and returns None if this is set to False. - - .. deprecated:: v0.8 - Argument has no use anymore and will be removed v0.9. kwargs: Additional keyword arguments, see :ref:`Metric kwargs` for more info. @@ -91,10 +86,9 @@ def __init__( self, fs: int, extended: bool = False, - compute_on_step: Optional[bool] = None, **kwargs: Dict[str, Any], ) -> None: - super().__init__(compute_on_step=compute_on_step, **kwargs) + super().__init__(**kwargs) if not _PYSTOI_AVAILABLE: raise ModuleNotFoundError( "STOI metric requires that `pystoi` is installed."