-
Notifications
You must be signed in to change notification settings - Fork 664
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add autograd test for T.AmplitudeToDB #1447
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this. Please refer to my comment.
sample_rate = 8000 | ||
transform = T.AmplitudeToDB() | ||
waveform = get_whitenoise(sample_rate=sample_rate, duration=0.05, n_channels=2) | ||
self.assert_grad(transform, [waveform], nondet_tol=1e-10) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you try it without nonfat_tol
?
With top_db=None
, it's just a combination of log10
, clamp
and multiplications.
If any of them are non deterministic, would be nice to add a comment about it here.
Also can you parameterize top_db
? Say, None
and 80
as recommended by the doc.
audio/torchaudio/functional/functional.py
Line 280 in 78c3480
if top_db is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad, I realized that when top_db
is provided the function uses torch.amax
, which is not differentiable. I think we should only test for the case top_db=None
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just made those changes let me know if this is okay.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Thanks!
Ref #1414
cc @mthrok