torchaudio.functional.mask_along_axis¶
- torchaudio.functional.mask_along_axis(specgram: Tensor, mask_param: int, mask_value: float, axis: int, p: float = 1.0) Tensor [source]¶
Apply a mask along
axis
.Mask will be applied from indices
[v_0, v_0 + v)
, wherev
is sampled fromuniform(0, max_v)
andv_0
fromuniform(0, specgram.size(axis) - v)
, withmax_v = mask_param
whenp = 1.0
andmax_v = min(mask_param, floor(specgram.size(axis) * p))
otherwise. All examples will have the same mask interval.- Parameters:
specgram (Tensor) – Real spectrograms (…, freq, time), with at least 2 dimensions.
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, which should be the one of the last two dimensions.
p (float, optional) – maximum proportion of columns that can be masked. (Default: 1.0)
- Returns:
Masked spectrograms with the same dimensions as input specgram Tensor
- Return type:
Tensor