Skip to content
heliaEDGE
Reference
HELIA

amplitude_warp

Classes

Name Description
AmplitudeWarp Amplitude warping layer

Machine-readable model

class

Apply amplitude warping to the 1D input.

helia_edge/layers/preprocessing/amplitude_warp.py:14

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 # 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.

Inherited from BaseAugmentation: augment_masks(), augment_sample(), augment_targets(), batch_augment(), call().

Parameters of AmplitudeWarp
NameTypeDefaultDescription
sample_ratefloat1Sample rate of the input.
frequencyfloat | tuple[float, float]100Frequency of the warping in Hz. If tuple, frequency is randomly picked between the values.
amplitudefloat | tuple[float, float]0.1Amplitude of the warping. If tuple, amplitude is randomly picked between the values.
method

Generate noise distortion tensor

helia_edge/layers/preprocessing/amplitude_warp.py:70

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

Generate noise distortion tensor

Parameters of get_random_transformations
NameTypeDefaultDescription
input_shapetuple[int, ...]RequiredInput shape.
Returns of get_random_transformations
ValueTypeDescription
dictdictDictionary containing the noise tensor.