# helia_edge.layers.preprocessing.amplitude_warp

## Amplitude Warp Layer

**Classes**

| Name | Description |
| --- | --- |
| `AmplitudeWarp` | Amplitude warping layer |

## helia_edge.layers.preprocessing.amplitude_warp.AmplitudeWarp

`class` · `python`

```python
AmplitudeWarp(
    sample_rate: float = 1,
    frequency: float | tuple[float, float] = 100,
    amplitude: float | tuple[float, float] = 0.1,
    **kwargs={},
)
```

Apply amplitude warping to the 1D input.
Time points are first generated at given frequency resolution with amplitude picked from uniform distribution.
These points are then interpolated to match the input duration and multiplied 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
amplitude = (0.5, 2) # Noise amplitude range
x = sig_amp*np.sin(2*np.pi*sig_freq*np.arange(duration)/sample_rate).reshape(-1, 1).astype(np.float32)
x = keras.ops.convert_to_tensor(x)
import helia_edge as helia

lyr = helia.layers.preprocessing.AmplitudeWarp(
    sample_rate=sample_rate,
    frequency=noise_freq,
    amplitude=amplitude,
)
y = lyr(x)
plt.plot(x.numpy())
plt.plot(y.numpy())
plt.show()
```



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 warping in Hz. If tuple, frequency is randomly picked between the values. |
| amplitude | float \| tuple[float, float] | 0.1 | Amplitude of the warping. If tuple, amplitude is randomly picked between the values. |

Source: `helia_edge/layers/preprocessing/amplitude_warp.py:14`

### helia_edge.layers.preprocessing.amplitude_warp.AmplitudeWarp.noise_type

`attribute` · `python`

```python
noise_type: str
```

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

### helia_edge.layers.preprocessing.amplitude_warp.AmplitudeWarp.sample_rate

`attribute` · `python`

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

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

### helia_edge.layers.preprocessing.amplitude_warp.AmplitudeWarp.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/amplitude_warp.py:67`

### helia_edge.layers.preprocessing.amplitude_warp.AmplitudeWarp.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/amplitude_warp.py:68`

### helia_edge.layers.preprocessing.amplitude_warp.AmplitudeWarp.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/amplitude_warp.py:70`

### helia_edge.layers.preprocessing.amplitude_warp.AmplitudeWarp.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/amplitude_warp.py:120`

### helia_edge.layers.preprocessing.amplitude_warp.AmplitudeWarp.get_config

`method` · `python`

```python
get_config()
```

Serialize the layer configuration to a JSON-compatible dictionary.

Source: `helia_edge/layers/preprocessing/amplitude_warp.py:127`
