# helia_edge.layers.preprocessing.random_background_noises

## Random Background Noises Layer API

This module provides classes to build random background noises layers.

**Classes**

| Name | Description |
| --- | --- |
| `RandomBackgroundNoises1D` | Random background noises 1D |

## helia_edge.layers.preprocessing.random_background_noises.RandomBackgroundNoises1D

`class` · `python`

```python
RandomBackgroundNoises1D(noises, amplitude: float | tuple[float, float] = 0.1, num_noises: int = 1, **kwargs={})
```

Apply random background noises to the input.

Example:

```python
    sample_rate = 100
    duration = 2*sample_rate
    freqs = [2, 5, 15, 20, 25]
    noises = np.vstack([
        np.sin(2*np.pi*f*np.arange(duration)/sample_rate)
        for f in freqs
    ]).T
    lyr = RandomBackgroundNoises(noises=noises, amplitude=0.2, num_noises=2)
    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_samples()](/helia-edge/reference/api/helia_edge/layers/preprocessing/base_augmentation/#helia_edge.layers.preprocessing.base_augmentation.BaseAugmentation.augment_samples), [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 |
| --- | --- | --- | --- |
| noises | np.ndarray | Required | Background noises to apply. |
| amplitude | float \| tuple[float, float] | 0.1 | Amplitude of the noise. If tuple, amplitude is randomly picked between the values. |

Source: `helia_edge/layers/preprocessing/random_background_noises.py:19`

### helia_edge.layers.preprocessing.random_background_noises.RandomBackgroundNoises1D.amplitude

`attribute` · `python`

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

Source: `helia_edge/layers/preprocessing/random_background_noises.py:47`

### helia_edge.layers.preprocessing.random_background_noises.RandomBackgroundNoises1D.num_noises

`attribute` · `python`

```python
num_noises: int = num_noises
```

Source: `helia_edge/layers/preprocessing/random_background_noises.py:48`

### helia_edge.layers.preprocessing.random_background_noises.RandomBackgroundNoises1D.noises

`attribute` · `python`

```python
noises = self.add_weight(name='noises', shape=noises.shape, initializer=keras.initializers.Constant(noises), trainable=False)
```

Source: `helia_edge/layers/preprocessing/random_background_noises.py:52`

### helia_edge.layers.preprocessing.random_background_noises.RandomBackgroundNoises1D.get_random_transformations

`method` · `python`

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

Generate noise 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_background_noises.py:56`

### helia_edge.layers.preprocessing.random_background_noises.RandomBackgroundNoises1D.augment_sample

`method` · `python`

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

Augment single sample with random background noises.

Source: `helia_edge/layers/preprocessing/random_background_noises.py:96`

### helia_edge.layers.preprocessing.random_background_noises.RandomBackgroundNoises1D.get_config

`method` · `python`

```python
get_config()
```

Serializes the configuration of the layer.

Source: `helia_edge/layers/preprocessing/random_background_noises.py:121`
