RandomBackgroundNoises1D
PythonApply random background noises to the input.
helia_edge/layers/preprocessing/random_background_noises.py:19
RandomBackgroundNoises1D(noises, amplitude: float | tuple[float, float] = 0.1, num_noises: int = 1, **kwargs={})Apply random background noises to the input.
Example:
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.
Inherited from BaseAugmentation: augment_masks(), augment_samples(), augment_targets(), batch_augment(), 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. |
amplitude
Pythonhelia_edge/layers/preprocessing/random_background_noises.py:47
amplitude: tuple[float, float] = parse_factor(amplitude, min_value=0, max_value=None, param_name='amplitude')num_noises
Pythonhelia_edge/layers/preprocessing/random_background_noises.py:48
num_noises: int = num_noisesnoises
Pythonhelia_edge/layers/preprocessing/random_background_noises.py:52
noises = self.add_weight(name='noises', shape=noises.shape, initializer=keras.initializers.Constant(noises), trainable=False)Generate noise tensor
helia_edge/layers/preprocessing/random_background_noises.py:56
get_random_transformations(input_shape: tuple[int, int, int]) -> dictGenerate noise 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_sample
PythonAugment single sample with random background noises.
helia_edge/layers/preprocessing/random_background_noises.py:96
augment_sample(inputs) -> keras.KerasTensorAugment single sample with random background noises.
get_config
PythonSerializes the configuration of the layer.
helia_edge/layers/preprocessing/random_background_noises.py:121
get_config()Serializes the configuration of the layer.