Skip to content

Commit

Permalink
Removed Deprecated compute_on_step from audio (#1007)
Browse files Browse the repository at this point in the history
* Removed Deprecated compute_on_step from audio
* Update CHANGELOG.md
* import fix
  • Loading branch information
tanmoyio authored May 5, 2022
1 parent 6144eb3 commit 1789b17
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 54 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
10 changes: 2 additions & 8 deletions torchmetrics/audio/pesq.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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."
Expand Down
10 changes: 2 additions & 8 deletions torchmetrics/audio/pit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.
Expand Down Expand Up @@ -74,15 +69,14 @@ 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] = {
"dist_sync_on_step": kwargs.pop("dist_sync_on_step", False),
"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
Expand Down
16 changes: 2 additions & 14 deletions torchmetrics/audio/sdr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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")
Expand Down
19 changes: 3 additions & 16 deletions torchmetrics/audio/snr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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")
Expand Down
10 changes: 2 additions & 8 deletions torchmetrics/audio/stoi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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."
Expand Down

0 comments on commit 1789b17

Please sign in to comment.