-
Notifications
You must be signed in to change notification settings - Fork 739
standardizing freq/time axis #401
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
Conversation
|
Test: import torch, torchaudio
torch.random.manual_seed(42)
specgram = torch.randn(1, 2, 5, 7)
torch.random.manual_seed(42)
output1 = torchaudio.functional.mask_along_axis_iid(specgram.clone(), mask_param=5, mask_value=0, axis=-1)
torch.random.manual_seed(42)
output2 = torchaudio.functional.mask_along_axis_iid(specgram.clone(), mask_param=5, mask_value=0, axis=3)
print(torch.allclose(output1, output2))
torch.random.manual_seed(42)
output1 = torchaudio.functional.mask_along_axis_iid(specgram.clone(), mask_param=5, mask_value=0, axis=-2)
torch.random.manual_seed(42)
output2 = torchaudio.functional.mask_along_axis_iid(specgram.clone(), mask_param=5, mask_value=0, axis=2)
print(torch.allclose(output1, output2))
torch.random.manual_seed(42)
output1 = torchaudio.functional.mask_along_axis(specgram.clone(), mask_param=5, mask_value=0, axis=2)
torch.random.manual_seed(42)
output2 = torchaudio.functional.mask_along_axis(specgram.clone(), mask_param=5, mask_value=0, axis=-1)
print(torch.allclose(output1, output2))
torch.random.manual_seed(42)
output1 = torchaudio.functional.mask_along_axis(specgram.clone(), mask_param=5, mask_value=0, axis=1)
torch.random.manual_seed(42)
output2 = torchaudio.functional.mask_along_axis(specgram.clone(), mask_param=5, mask_value=0, axis=-2)
print(torch.allclose(output1, output2))True
True
True
True |
|
@mthrok -- thoughts on this convention? |
mthrok
left a comment
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.
|
|
||
| if axis != 2 and axis != 3: | ||
| if axis != -2 and axis != -1: | ||
| raise ValueError('Only Frequency and Time masking are supported') |
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.
I feel it a little bit too strict to disallow positive indices, but as long as it is explained in doctoring, I think it's fair.
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.
oh wait, isn't this BC breaking?
| """ | ||
|
|
||
| if axis != 2 and axis != 3: | ||
| if axis != -2 and axis != -1: |
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.
nit
| if axis != -2 and axis != -1: | |
| if axis not in [-1, -2]: |
|
Unless there is a request for this, let's not do this BC-breaking change. |
Let's use the same convention between masking functions (lines 826 and 862), while also aligning with the batching convention we use (lines 823 and 829), see #391.
Reference: #285