-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -823,13 +823,13 @@ def mask_along_axis_iid(specgrams, mask_param, mask_value, axis): | |
| specgrams (Tensor): Real spectrograms (batch, channel, freq, time) | ||
| mask_param (int): Number of columns to be masked will be uniformly sampled from [0, mask_param] | ||
| mask_value (float): Value to assign to the masked columns | ||
| axis (int): Axis to apply masking on (2 -> frequency, 3 -> time) | ||
| axis (int): Axis to apply masking on (-2 -> frequency, -1 -> time) | ||
|
|
||
| Returns: | ||
| torch.Tensor: Masked spectrograms of dimensions (batch, channel, freq, time) | ||
| """ | ||
|
|
||
| if axis != 2 and axis != 3: | ||
| if axis != -2 and axis != -1: | ||
| raise ValueError('Only Frequency and Time masking are supported') | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh wait, isn't this BC breaking? |
||
|
|
||
| value = torch.rand(specgrams.shape[:2]) * mask_param | ||
|
|
@@ -859,7 +859,7 @@ def mask_along_axis(specgram, mask_param, mask_value, axis): | |
| specgram (Tensor): Real spectrogram (channel, freq, time) | ||
| mask_param (int): Number of columns to be masked will be uniformly sampled from [0, mask_param] | ||
| mask_value (float): Value to assign to the masked columns | ||
| axis (int): Axis to apply masking on (1 -> frequency, 2 -> time) | ||
| axis (int): Axis to apply masking on (-2 -> frequency, -1 -> time) | ||
|
|
||
| Returns: | ||
| torch.Tensor: Masked spectrogram of dimensions (channel, freq, time) | ||
|
|
@@ -876,9 +876,9 @@ def mask_along_axis(specgram, mask_param, mask_value, axis): | |
| mask_end = (min_value.long() + value.long()).squeeze() | ||
|
|
||
| assert mask_end - mask_start < mask_param | ||
| if axis == 1: | ||
| if axis == -2: | ||
| specgram[:, mask_start:mask_end] = mask_value | ||
| elif axis == 2: | ||
| elif axis == -1: | ||
| specgram[:, :, mask_start:mask_end] = mask_value | ||
| else: | ||
| 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.
nit