torchaudio.functional.mask_along_axis_iid(specgrams: Tensor, mask_param: int, mask_value: float, axis: int, p: float = 1.0) Tensor[source]

Apply a mask along axis.

This feature supports the following devices: CPU, CUDA This API supports the following properties: Autograd, TorchScript

Mask will be applied from indices [v_0, v_0 + v), where v is sampled from uniform(0, max_v) and v_0 from uniform(0, specgrams.size(axis) - v), with max_v = mask_param when p = 1.0 and max_v = min(mask_param, floor(specgrams.size(axis) * p)) otherwise.

  • specgrams (Tensor) – Real spectrograms (…, freq, time), with at least 3 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)


Masked spectrograms with the same dimensions as input specgrams Tensor`

Return type:



Access comprehensive developer documentation for PyTorch

View Docs


Get in-depth tutorials for beginners and advanced developers

View Tutorials


Find development resources and get your questions answered

View Resources