das.augmentation

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)

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.

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

Bundles several augmentations.

Parameters

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

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

Circularly shift input along the first axis.

Parameters

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

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

Constant parameter.

Parameters

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

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

Multiply signal with gain factor.

Parameters

gain (Param) – Gain.

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

Horizontally flip signal.

Parameters

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.

Parameters

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.

Parameters
  • 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.

Parameters
  • 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.Offset(offset: das.augmentation.Param)[source]

Add horizontal offset.

Parameters

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.

Parameters
  • 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.

Parameters

factor (Param) – Upsampling factor.

Raises

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