RandomNoiseDistortion1D
PythonApply 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
| Name | Type | Default | Description |
|---|---|---|---|
sample_rate | float | 1 | Sample rate of the input. |
frequency | float | tuple[float, float] | 100 | Frequency of the noise in Hz. If tuple, frequency is randomly picked between the values. |
amplitude | float | tuple[float, float] | 0.1 | Amplitude of the noise. If tuple, amplitude is randomly picked between the values. |
interpolation | str | 'bilinear' | Interpolation method to use. One of "nearest", "bilinear", or "bicubic". |
noise_type | str | 'normal' | Type of noise to generate. Currently only "normal" is supported. |
sample_rate
Pythonhelia_edge/layers/preprocessing/random_noise_distortion.py:64
sample_rate: float = sample_ratefrequency
Pythonhelia_edge/layers/preprocessing/random_noise_distortion.py:65
frequency: tuple[float, float] = parse_factor(frequency, min_value=None, max_value=sample_rate / 2, param_name='frequency')amplitude
Pythonhelia_edge/layers/preprocessing/random_noise_distortion.py:66
amplitude: tuple[float, float] = parse_factor(amplitude, min_value=None, max_value=None, param_name='amplitude')interpolation
Pythonhelia_edge/layers/preprocessing/random_noise_distortion.py:67
interpolation: str = interpolationnoise_type
Pythonhelia_edge/layers/preprocessing/random_noise_distortion.py:68
noise_type: str = noise_typeGenerate noise distortion tensor
helia_edge/layers/preprocessing/random_noise_distortion.py:70
get_random_transformations(input_shape: tuple[int, int, int]) -> dictGenerate noise distortion tensor
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
input_shape | tuple[int, ...] | Required | Input shape. |
Returns
| Value | Type | Description |
|---|---|---|
dict | dict | Dictionary containing the noise tensor. |
augment_samples
PythonAugment all samples in the batch as it's faster.
helia_edge/layers/preprocessing/random_noise_distortion.py:122
augment_samples(inputs) -> keras.KerasTensorAugment all samples in the batch as it’s faster.
get_config
PythonSerialize the layer configuration to a JSON-compatible dictionary.
helia_edge/layers/preprocessing/random_noise_distortion.py:129
get_config()Serialize the layer configuration to a JSON-compatible dictionary.