# helia_edge.layers.preprocessing.random_noise_distortion

## Random Noise Distortion Layer API

This module provides classes to build random noise distortion layers.

**Classes**

| Name | Description |
| --- | --- |
| `RandomNoiseDistortion1D` | Random noise distortion 1D |

## helia_edge.layers.preprocessing.random_noise_distortion.RandomNoiseDistortion1D

`class` · `python`

```python
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:

```python
    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](/helia-edge/reference/api/helia_edge/layers/preprocessing/base_augmentation/#helia_edge.layers.preprocessing.base_augmentation.BaseAugmentation1D).

Inherited from [BaseAugmentation](/helia-edge/reference/api/helia_edge/layers/preprocessing/base_augmentation/#helia_edge.layers.preprocessing.base_augmentation.BaseAugmentation): [augment_masks()](/helia-edge/reference/api/helia_edge/layers/preprocessing/base_augmentation/#helia_edge.layers.preprocessing.base_augmentation.BaseAugmentation.augment_masks), [augment_sample()](/helia-edge/reference/api/helia_edge/layers/preprocessing/base_augmentation/#helia_edge.layers.preprocessing.base_augmentation.BaseAugmentation.augment_sample), [augment_targets()](/helia-edge/reference/api/helia_edge/layers/preprocessing/base_augmentation/#helia_edge.layers.preprocessing.base_augmentation.BaseAugmentation.augment_targets), [batch_augment()](/helia-edge/reference/api/helia_edge/layers/preprocessing/base_augmentation/#helia_edge.layers.preprocessing.base_augmentation.BaseAugmentation.batch_augment), [call()](/helia-edge/reference/api/helia_edge/layers/preprocessing/base_augmentation/#helia_edge.layers.preprocessing.base_augmentation.BaseAugmentation.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. |

Source: `helia_edge/layers/preprocessing/random_noise_distortion.py:17`

### helia_edge.layers.preprocessing.random_noise_distortion.RandomNoiseDistortion1D.sample_rate

`attribute` · `python`

```python
sample_rate: float = sample_rate
```

Source: `helia_edge/layers/preprocessing/random_noise_distortion.py:64`

### helia_edge.layers.preprocessing.random_noise_distortion.RandomNoiseDistortion1D.frequency

`attribute` · `python`

```python
frequency: tuple[float, float] = parse_factor(frequency, min_value=None, max_value=sample_rate / 2, param_name='frequency')
```

Source: `helia_edge/layers/preprocessing/random_noise_distortion.py:65`

### helia_edge.layers.preprocessing.random_noise_distortion.RandomNoiseDistortion1D.amplitude

`attribute` · `python`

```python
amplitude: tuple[float, float] = parse_factor(amplitude, min_value=None, max_value=None, param_name='amplitude')
```

Source: `helia_edge/layers/preprocessing/random_noise_distortion.py:66`

### helia_edge.layers.preprocessing.random_noise_distortion.RandomNoiseDistortion1D.interpolation

`attribute` · `python`

```python
interpolation: str = interpolation
```

Source: `helia_edge/layers/preprocessing/random_noise_distortion.py:67`

### helia_edge.layers.preprocessing.random_noise_distortion.RandomNoiseDistortion1D.noise_type

`attribute` · `python`

```python
noise_type: str = noise_type
```

Source: `helia_edge/layers/preprocessing/random_noise_distortion.py:68`

### helia_edge.layers.preprocessing.random_noise_distortion.RandomNoiseDistortion1D.get_random_transformations

`method` · `python`

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

Generate noise distortion tensor

**Parameters**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| input_shape | tuple[int, ...] | Required | Input shape. |

**Returns**

| Name | Type | Description |
| --- | --- | --- |
| dict | dict | Dictionary containing the noise tensor. |

Source: `helia_edge/layers/preprocessing/random_noise_distortion.py:70`

### helia_edge.layers.preprocessing.random_noise_distortion.RandomNoiseDistortion1D.augment_samples

`method` · `python`

```python
augment_samples(inputs) -> keras.KerasTensor
```

Augment all samples in the batch as it's faster.

Source: `helia_edge/layers/preprocessing/random_noise_distortion.py:122`

### helia_edge.layers.preprocessing.random_noise_distortion.RandomNoiseDistortion1D.get_config

`method` · `python`

```python
get_config()
```

Serialize the layer configuration to a JSON-compatible dictionary.

Source: `helia_edge/layers/preprocessing/random_noise_distortion.py:129`
