mindspore.dataset.audio.MaskAlongAxisIID

View Source On Gitee
class mindspore.dataset.audio.MaskAlongAxisIID(mask_param, mask_value, axis)[source]

Apply a mask along axis . Mask will be applied from indices [mask_start, mask_start + mask_width) , where mask_width is sampled from uniform[0, mask_param] , and mask_start from uniform[0, max_length - mask_width] , max_length is the number of columns of the specified axis of the spectrogram.

Parameters
  • mask_param (int) – Number of columns to be masked, will be uniformly sampled from [0, mask_param], must be non negative.

  • mask_value (float) – Value to assign to the masked columns.

  • axis (int) – Axis to apply mask on (1 for frequency and 2 for time).

Raises
  • TypeError – If mask_param is not of type int.

  • ValueError – If mask_param is a negative value.

  • TypeError – If mask_value is not of type float.

  • TypeError – If axis is not of type int.

  • ValueError – If axis is not in range of [1, 2].

  • RuntimeError – If input tensor is not in shape of <…, freq, time>.

Supported Platforms:

CPU

Examples

>>> import numpy as np
>>> import mindspore.dataset as ds
>>> import mindspore.dataset.audio as audio
>>>
>>> waveform= np.random.random([1, 20, 20])
>>> numpy_slices_dataset = ds.NumpySlicesDataset(data=waveform, column_names=["audio"])
>>> transforms = [audio.MaskAlongAxisIID(5, 0.5, 2)]
>>> numpy_slices_dataset = numpy_slices_dataset.map(operations=transforms, input_columns=["audio"])
Tutorial Examples: