Waveform level augmentations.

Individual implementations of Augmentation are callables that accept the signal to augment as an argument and return the augmented signal.

Augmentation parameters can be Constant, or random with Normal or Uniform distribution. Random parameters will be sampled from a given distribution anew for each augmentation.

aug = Gain(gain=Normal(mean=1, std=0.5)); augmented_signal = aug(signal)

Can be configured using a yaml file: ```yaml Gain: # Name of the augmentation class

gain: # arg for the augmentation class
Uniform: # Param type

lower: 0.5 # param args upper: 2 # param args


mean: 0 std: 0.05


value: 0

freq: # Param-type arg

lower: 100 upper: 600

Q: 30 # standard arg samplerate_Hz: 10_000 # standard arg

``` Caution: You need to add a suffix starting with ‘-’ (like “MaskNoise-1”) to the class name

if you want to use a class multiple times

augs = Augmentations.from_yaml(filename)

class das.augmentation.Augmentation[source]#

Base class for all augmentations.

Augmentations are callables that return the augmented input. Can optionally pass through a second input.

batch_x is expected to be [batch, time, channel]. _apply works on [time, channel] inputs

class das.augmentation.Augmentations(augmentations: List[das.augmentation.Augmentation])[source]#

Bundles several augmentations.


augmentations (List[Augmentation]) – List of Augmentation instances.

class das.augmentation.CircShift(shift: das.augmentation.Param)[source]#

Circularly shift input along the first axis.


shift (Param) – Amount of shift, in samples.

class das.augmentation.Constant(value: float = 0.0)[source]#

Constant parameter.


value (float, optional) – Constant parameter value. Defaults to 0.0.

class das.augmentation.Gain(gain: das.augmentation.Param)[source]#

Multiply signal with gain factor.


gain (Param) – Gain.

class das.augmentation.HorizontalFlip(flip: das.augmentation.Param)[source]#

Horizontally flip signal.


flip (Param) – Signal is flipped if >0.

class das.augmentation.MaskMean(duration: das.augmentation.Param)[source]#

Replaces stretch of duration samples with mean over that stretch.


duration (Param) – Duration of the stretch, in samples.

class das.augmentation.MaskNoise(std: Optional[das.augmentation.Param] = None, mean: Optional[das.augmentation.Param] = None, duration: Optional[das.augmentation.Param] = None, add: bool = True)[source]#

Add noise or replace signal by noise for the full duration or a part of it.

  • std (Optional[Param]) – std of noise. Defaults to 1.

  • mean (Optional[Param]) – mean of noise. Defaults to 0.

  • duration (Optional[Param]) – nb_samples, Optional. If omitted will mask full duration.

  • add (bool) – add or replace. Defaults to True.

class das.augmentation.Normal(mean: float = 0.0, std: float = 1.0)[source]#

Normally distributed parameter.

  • mean (float, optional) – Mean of the Normal pdf. Defaults to 0.0.

  • std (float, optional) – Standerd deviation of the Normal pdf. Defaults to 1.0.

class das.augmentation.NormalizeMax[source]#

Multiply signal with gain factor.

class das.augmentation.NormalizePercentile(percentile: das.augmentation.Param)[source]#

Multiply signal with gain factor.

class das.augmentation.NormalizeStd[source]#

Multiply signal with gain factor.

class das.augmentation.NotchFilter(freq: das.augmentation.Param, Q: float = 30, samplerate_Hz: float = 10000)[source]#

Notch filter.


freq (Param) – freq to remove, in Hz.

class das.augmentation.Offset(offset: das.augmentation.Param)[source]#

Add horizontal offset.


offset (Param) – Offset.

class das.augmentation.Param[source]#

Base class for all parameters.

Parameters are callables that return parameter values.

class das.augmentation.Uniform(lower: float = - 1.0, upper: float = 1.0)[source]#

Uniformly distributed parameter.

  • lower (float, optional) – Lower bound. Defaults to -1.0.

  • upper (float, optional) – Upper bound. Defaults to 1.0.

class das.augmentation.Upsampling(factor: das.augmentation.Param)[source]#

Upsample signal.


factor (Param) – Upsampling factor.


ValueError – if ‘lower’ attr of factor is <1 (would correspond to downsampling).