mindspore.dataset.audio.ComplexNorm

class mindspore.dataset.audio.ComplexNorm(power=1.0)[source]

Compute the norm of complex number sequence.

Note

The shape of the audio waveform to be processed needs to be <…, complex=2>. The first dimension represents the real part while the second represents the imaginary.

Parameters

power (float, optional) – Power of the norm, which must be non-negative. Default: 1.0.

Raises
  • TypeError – If power is not of type float.

  • ValueError – If power is a negative number.

  • RuntimeError – If input tensor is not in shape of <…, complex=2>.

Supported Platforms:

CPU

Examples

>>> import numpy as np
>>> import mindspore.dataset as ds
>>> import mindspore.dataset.audio as audio
>>>
>>> # Use the transform in dataset pipeline mode
>>> waveform = np.random.random([5, 16, 2])  # 5 samples
>>> numpy_slices_dataset = ds.NumpySlicesDataset(data=waveform, column_names=["audio"])
>>> transforms = [audio.ComplexNorm()]
>>> numpy_slices_dataset = numpy_slices_dataset.map(operations=transforms, input_columns=["audio"])
>>> for item in numpy_slices_dataset.create_dict_iterator(num_epochs=1, output_numpy=True):
...     print(item["audio"].shape, item["audio"].dtype)
...     break
(16,) float64
>>>
>>> # Use the transform in eager mode
>>> waveform = np.random.random([16, 2])  # 1 samples
>>> output = audio.ComplexNorm()(waveform)
>>> print(output.shape, output.dtype)
(16,) float64
Tutorial Examples: