From a68ff4f9cb2ea5d5295dc06c88b14991e858b26f Mon Sep 17 00:00:00 2001 From: lbjcom Date: Thu, 25 Jun 2020 05:44:15 +0900 Subject: [PATCH 1/4] Update functional.py rollback torch.norm() in spectrogram() to v0.4.0. --- torchaudio/functional.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/torchaudio/functional.py b/torchaudio/functional.py index 28cb6a3fa2..031858b3d5 100644 --- a/torchaudio/functional.py +++ b/torchaudio/functional.py @@ -169,6 +169,9 @@ def spectrogram( spec_f /= window.pow(2.).sum().sqrt() if power is not None: spec_f = complex_norm(spec_f, power=power) + # Replace by torch.norm once issue is fixed + # https://github.com/pytorch/pytorch/issues/34279 + spec_f = spec_f.pow(2.).sum(-1).pow(0.5 * power) return spec_f From b89c513639408f5629aedbe99fbb010e4547cfa9 Mon Sep 17 00:00:00 2001 From: lbjcom Date: Thu, 25 Jun 2020 06:27:52 +0900 Subject: [PATCH 2/4] Update functional.py comment out `spec_f = complex_norm(spec_f, power=power)`. --- torchaudio/functional.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/torchaudio/functional.py b/torchaudio/functional.py index 031858b3d5..13f8b128a2 100644 --- a/torchaudio/functional.py +++ b/torchaudio/functional.py @@ -168,7 +168,7 @@ def spectrogram( if normalized: spec_f /= window.pow(2.).sum().sqrt() if power is not None: - spec_f = complex_norm(spec_f, power=power) + # spec_f = complex_norm(spec_f, power=power) # Replace by torch.norm once issue is fixed # https://github.com/pytorch/pytorch/issues/34279 spec_f = spec_f.pow(2.).sum(-1).pow(0.5 * power) From 982626f06eeac1831240e749231f813cc70678b5 Mon Sep 17 00:00:00 2001 From: "bongjin.lee" Date: Fri, 26 Jun 2020 09:19:32 +0900 Subject: [PATCH 3/4] fixed complex_norm() instead of spectrogram() for torch.norm() issue. --- torchaudio/functional.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/torchaudio/functional.py b/torchaudio/functional.py index 13f8b128a2..275d921a4c 100644 --- a/torchaudio/functional.py +++ b/torchaudio/functional.py @@ -168,10 +168,8 @@ def spectrogram( if normalized: spec_f /= window.pow(2.).sum().sqrt() if power is not None: - # spec_f = complex_norm(spec_f, power=power) - # Replace by torch.norm once issue is fixed - # https://github.com/pytorch/pytorch/issues/34279 - spec_f = spec_f.pow(2.).sum(-1).pow(0.5 * power) + spec_f = complex_norm(spec_f, power=power) + return spec_f @@ -488,9 +486,10 @@ def complex_norm( Returns: Tensor: Power of the normed input tensor. Shape of `(..., )` """ - if power == 1.0: - return torch.norm(complex_tensor, 2, -1) - return torch.norm(complex_tensor, 2, -1).pow(power) + + # Replace by torch.norm once issue is fixed + # https://github.com/pytorch/pytorch/issues/34279 + return complex_tensor.pow(2.).sum(-1).pow(0.5 * power) def angle( From 990bb5e57b66c92254365fdd6e43a12d9d0b7c78 Mon Sep 17 00:00:00 2001 From: Vincent QB Date: Fri, 26 Jun 2020 10:42:02 -0400 Subject: [PATCH 4/4] lint --- torchaudio/functional.py | 1 - 1 file changed, 1 deletion(-) diff --git a/torchaudio/functional.py b/torchaudio/functional.py index 275d921a4c..78c8c594c9 100644 --- a/torchaudio/functional.py +++ b/torchaudio/functional.py @@ -169,7 +169,6 @@ def spectrogram( spec_f /= window.pow(2.).sum().sqrt() if power is not None: spec_f = complex_norm(spec_f, power=power) - return spec_f