Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
Torchaudio
Commits
69293315
Unverified
Commit
69293315
authored
Apr 06, 2021
by
Chin-Yun Yu
Committed by
GitHub
Apr 06, 2021
Browse files
Add autograd test for T.GriffinLim (#1421)
parent
b388d48e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
2 deletions
+11
-2
test/torchaudio_unittest/transforms/autograd_test_impl.py
test/torchaudio_unittest/transforms/autograd_test_impl.py
+9
-0
torchaudio/functional/functional.py
torchaudio/functional/functional.py
+1
-1
torchaudio/transforms.py
torchaudio/transforms.py
+1
-1
No files found.
test/torchaudio_unittest/transforms/autograd_test_impl.py
View file @
69293315
...
@@ -65,6 +65,15 @@ class AutogradTestMixin(TestBaseMixin):
...
@@ -65,6 +65,15 @@ class AutogradTestMixin(TestBaseMixin):
waveform
=
get_whitenoise
(
sample_rate
=
sample_rate
,
duration
=
0.05
,
n_channels
=
2
)
waveform
=
get_whitenoise
(
sample_rate
=
sample_rate
,
duration
=
0.05
,
n_channels
=
2
)
self
.
assert_grad
(
transform
,
[
waveform
],
nondet_tol
=
1e-10
)
self
.
assert_grad
(
transform
,
[
waveform
],
nondet_tol
=
1e-10
)
@
parameterized
.
expand
([(
0
,
),
(
0.99
,
)])
def
test_griffinlim
(
self
,
momentum
):
n_fft
=
400
n_frames
=
5
n_iter
=
3
spec
=
torch
.
rand
(
n_fft
//
2
+
1
,
n_frames
)
*
n_fft
transform
=
T
.
GriffinLim
(
n_fft
=
n_fft
,
n_iter
=
n_iter
,
momentum
=
momentum
,
rand_init
=
False
)
self
.
assert_grad
(
transform
,
[
spec
],
nondet_tol
=
1e-10
)
@
parameterized
.
expand
([(
False
,
),
(
True
,
)])
@
parameterized
.
expand
([(
False
,
),
(
True
,
)])
def
test_mfcc
(
self
,
log_mels
):
def
test_mfcc
(
self
,
log_mels
):
sample_rate
=
8000
sample_rate
=
8000
...
...
torchaudio/functional/functional.py
View file @
69293315
...
@@ -203,7 +203,7 @@ def griffinlim(
...
@@ -203,7 +203,7 @@ def griffinlim(
hop_length
=
hop_length
,
hop_length
=
hop_length
,
win_length
=
win_length
,
win_length
=
win_length
,
window
=
window
,
window
=
window
,
length
=
length
)
.
float
()
length
=
length
)
# Rebuild the spectrogram
# Rebuild the spectrogram
rebuilt
=
torch
.
view_as_real
(
rebuilt
=
torch
.
view_as_real
(
...
...
torchaudio/transforms.py
View file @
69293315
...
@@ -172,7 +172,7 @@ class GriffinLim(torch.nn.Module):
...
@@ -172,7 +172,7 @@ class GriffinLim(torch.nn.Module):
super
(
GriffinLim
,
self
).
__init__
()
super
(
GriffinLim
,
self
).
__init__
()
assert
momentum
<
1
,
'momentum={} > 1 can be unstable'
.
format
(
momentum
)
assert
momentum
<
1
,
'momentum={} > 1 can be unstable'
.
format
(
momentum
)
assert
momentum
>
0
,
'momentum={} < 0'
.
format
(
momentum
)
assert
momentum
>
=
0
,
'momentum={} < 0'
.
format
(
momentum
)
self
.
n_fft
=
n_fft
self
.
n_fft
=
n_fft
self
.
n_iter
=
n_iter
self
.
n_iter
=
n_iter
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment