AmplitudeWarp
PythonApply amplitude warping to the 1D input.
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:
sample_rate = 100 # Hzduration = 3*sample_rate # 3 secondssig_freq = 10 # Hzsig_amp = 1 # Signal amplitudenoise_freq = (1, 2) # Noise frequency rangeamplitude = (0.5, 2) # Noise amplitude rangex = 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.
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 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. |
noise_type
Pythonnoise_type: strsample_rate
Pythonsample_rate: float = sample_ratefrequency
Pythonfrequency: tuple[float, float] = parse_factor(frequency, min_value=None, max_value=sample_rate / 2, param_name='frequency')amplitude
Pythonamplitude: tuple[float, float] = parse_factor(amplitude, min_value=0, max_value=None, param_name='amplitude')Generate noise distortion tensor
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.
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.
get_config()Serialize the layer configuration to a JSON-compatible dictionary.