Skip to content
heliaEDGE
Reference
HELIA

random_noise_distortion

This module provides classes to build random noise distortion layers.

Classes

Name Description
RandomNoiseDistortion1D Random noise distortion 1D

Machine-readable model

class

Apply random noise distortion to the 1D input.

helia_edge/layers/preprocessing/random_noise_distortion.py:17

RandomNoiseDistortion1D(
sample_rate: float = 1,
frequency: float | tuple[float, float] = 100,
amplitude: float | tuple[float, float] = 0.1,
interpolation: str = 'bilinear',
noise_type: str = 'normal',
**kwargs={},
)

Apply random noise distortion to the 1D input. Noise points are first generated at given frequency resolution with amplitude picked based on noise_type. The noise points are then interpolated to match the input duration and added to the input.

Example:

sample_rate = 100 # Hz
duration = 3*sample_rate # 3 seconds
sig_freq = 10 # Hz
sig_amp = 1 # Signal amplitude
noise_freq = (1, 2) # Noise frequency range
noise_amp = (1, 2) # Noise amplitude range
x = sig_amp*np.sin(2*np.pi*sig_freq*np.arange(duration)/sample_rate).reshape(-1, 1)
lyr = RandomNoiseDistortion1D(sample_rate=sample_rate, frequency=noise_freq, amplitude=noise_amp)
y = lyr(x, training=True)

Base class: BaseAugmentation1D.

Inherited from BaseAugmentation: augment_masks(), augment_sample(), augment_targets(), batch_augment(), call().

Parameters of RandomNoiseDistortion1D
NameTypeDefaultDescription
sample_ratefloat1Sample rate of the input.
frequencyfloat | tuple[float, float]100Frequency of the noise in Hz. If tuple, frequency is randomly picked between the values.
amplitudefloat | tuple[float, float]0.1Amplitude of the noise. If tuple, amplitude is randomly picked between the values.
interpolationstr'bilinear'Interpolation method to use. One of "nearest", "bilinear", or "bicubic".
noise_typestr'normal'Type of noise to generate. Currently only "normal" is supported.
method

Generate noise distortion tensor

helia_edge/layers/preprocessing/random_noise_distortion.py:70

get_random_transformations(input_shape: tuple[int, int, int]) -> dict

Generate noise distortion tensor

Parameters of get_random_transformations
NameTypeDefaultDescription
input_shapetuple[int, ...]RequiredInput shape.
Returns of get_random_transformations
ValueTypeDescription
dictdictDictionary containing the noise tensor.