Skip to content

augmentation_pipeline

Augmentation Pipeline API

Classes:

Classes

AugmentationPipeline

AugmentationPipeline(layers: list[keras.Layer], name: str | None = None, force_training: bool = False)

Pipeline of augmentation layers.

Parameters:

  • layers (list[Layer]) –

    List of augmentation layers.

  • force_training (bool, default: False ) –

    Force training mode. Defaults to False.

Example:

layers = [
    nse.layers.preprocessing.RandomNoiseDistortion1D(sample_rate=100, frequency=(1, 2), amplitude=(0.5, 2)),
    nse.layers.preprocessing.AmplitudeWarp(sample_rate=100, frequency=(1, 2), amplitude=(0.5, 2)),
]
pipeline = nse.layers.preprocessing.AugmentationPipeline(layers)
x = keras.random.normal((10, 100, 1), dtype="float32")
x_aug = pipeline(x, training=True)
plt.plot(x[0].numpy())
plt.plot(x_aug[0].numpy())
plt.show()
Source code in neuralspot_edge/layers/preprocessing/augmentation_pipeline.py
def __init__(
    self,
    layers: list[keras.Layer],
    name: str | None = None,
    force_training: bool = False,
):
    """Pipeline of augmentation layers.

    Args:
        layers (list[keras.Layer]): List of augmentation layers.
        force_training (bool, optional): Force training mode. Defaults to False.

    Example:

    ```python
    layers = [
        nse.layers.preprocessing.RandomNoiseDistortion1D(sample_rate=100, frequency=(1, 2), amplitude=(0.5, 2)),
        nse.layers.preprocessing.AmplitudeWarp(sample_rate=100, frequency=(1, 2), amplitude=(0.5, 2)),
    ]
    pipeline = nse.layers.preprocessing.AugmentationPipeline(layers)
    x = keras.random.normal((10, 100, 1), dtype="float32")
    x_aug = pipeline(x, training=True)
    plt.plot(x[0].numpy())
    plt.plot(x_aug[0].numpy())
    plt.show()
    ```
    """
    super().__init__(name=name)
    self.layers = layers
    self.force_training = force_training

Functions