Esc
Ask AIAnswers may be inaccurate; check the linked pages.Esc
Ask anything about these docs, like how to get started or what a function does.

ApplyAugmentations

augmentations.ApplyAugmentations

Applies a list of transformations randomly to two concatenated inputs (ip1 and ip2) and returns the augmented inputs split back into two tensors.

__init__(self, transforms)

Initializes the augmentation module, wrapping the provided transformations in RandomApply.

Parameter Type Default Description
transforms - - (undocumented)

forward(self, ip1, ip2)

Applies the transformations to the concatenated inputs.

Parameter Type Default Description
ip1 - - (undocumented)
ip2 - - (undocumented)

Returns: tuple[torch.Tensor, torch.Tensor] (The two augmented tensors, op1 and op2).

RandomApply

augmentations.RandomApply

Applies a list of transformation modules (transforms) to the input data x with a specified probability p.

__init__(self, transforms, p=0.5)

Initializes the module with a list of transformations and an application probability.

Parameter Type Default Description
transforms - - A list of transformation modules to be applied to the input data. These could be any transformations like normalization, augmentation, etc.
p float 0.5 The probability with which the transformations will be applied. It's a floating-point number between 0 and 1.

forward(self, x)

Applies the transformations to the input tensor x based on the probability p.

Parameter Type Default Description
x - - (undocumented)

Returns: torch.Tensor (The input tensor, potentially transformed).

Jitter

augmentations.Jitter

The Jitter class implements a jittering transformation as described in the paper: 'Data Augmentation for Machine Learning Algorithms' (https://arxiv.org/pdf/1706.00527.pdf). It adds random noise to the input data, which is a common technique for data augmentation.

__init__(self, p, sigma=0.03)

Initializes the Jitter module.

Parameter Type Default Description
p - - The probability with which the jitter (noise) will be applied to the input data.
sigma float 0.03 Defines the standard deviation of the normal distribution used for generating the jitter. It controls the magnitude of the noise added to the data.

forward(self, x)

Applies random noise to the input data based on probability p.

Parameter Type Default Description
x - - (undocumented)

Returns: torch.Tensor (The input tensor with added noise (if applied)).

Scaling

augmentations.Scaling

The Scaling class implements a scaling transformation as described in the paper: 'Data Augmentation for Machine Learning Algorithms' (https://arxiv.org/pdf/1706.00527.pdf). This transformation scales the input data by a random factor, which can be useful for data augmentation.

__init__(self, p, sigma=0.1)

Initializes the Scaling module.

Parameter Type Default Description
p - - The probability with which the scaling will be applied to the input data.
sigma float 0.1 Defines the standard deviation of the normal distribution used for generating the scaling factor. It controls the variability of the scaling factor.

forward(self, x)

Scales the input data by a random factor based on probability p.

Parameter Type Default Description
x - - (undocumented)

Returns: torch.Tensor (The input tensor scaled by a random factor (if applied)).

Rotation

augmentations.Rotation

This Rotation class is designed to randomly rotate the input data. It's a form of data augmentation that can be particularly useful in scenarios where the orientation of the data is not a defining characteristic.

__init__(self, p)

Initializes the Rotation module.

Parameter Type Default Description
p - - The probability of applying the rotation to the input data.

forward(self, x)

Randomly rotates the input data based on probability p.

Parameter Type Default Description
x - - (undocumented)

Returns: torch.Tensor (The input tensor, randomly rotated (if applied)).

Permutation

augmentations.Permutation

The Permutation class implements a data augmentation technique where the data is divided into segments, and these segments are then randomly permuted. This can be useful for tasks where the order of data points is not crucial and can help in improving the robustness of models.

__init__(self, p, max_segments=5, seg_mode="equal")

Initializes the Permutation module.

Parameter Type Default Description
p - - The probability of applying the permutation to the input data.
max_segments int 5 Defines the maximum number of segments into which the data can be split for permutation.
seg_mode str "equal" Determines how the segments are created: 'equal' for equal-sized segments, 'random' for random splits.

forward(self, x)

Applies random permutation of segments to the input data based on probability p.

Parameter Type Default Description
x - - (undocumented)

Returns: torch.Tensor (The input tensor with segments randomly permuted (if applied)).

MagnitudeWarp

augmentations.MagnitudeWarp

The MagnitudeWarp class applies a non-linear warping to the magnitude of the input data. This is achieved by using cubic splines to create smooth, random warp functions that are then applied to the input. It's a form of data augmentation useful in scenarios where the model needs to be robust to variations in the magnitude of the input data.

__init__(self, p, sigma=0.2, knot=4)

Initializes the MagnitudeWarp module.

Parameter Type Default Description
p - - The probability with which the magnitude warp will be applied.
sigma float 0.2 Controls the variability of the warp. Higher values lead to more pronounced warping.
knot int 4 The number of points in the cubic spline used for warping.

forward(self, x)

Applies non-linear magnitude warping to the input data based on probability p.

Parameter Type Default Description
x - - (undocumented)

Returns: torch.Tensor (The input tensor with magnitude warping applied (if applied)).

TimeWarp

augmentations.TimeWarp

The TimeWrap class applies a non-linear warping to the time axis of the input data. This is achieved by using cubic splines to create smooth, random warp functions that distort the time dimension of the input. It's a form of data augmentation useful for tasks where the model needs to be robust to variations in the timing of the input data.

__init__(self, p, sigma=0.2, knot=4)

Initializes the TimeWarp module.

Parameter Type Default Description
p - - The probability with which the time warp will be applied.
sigma float 0.2 Controls the variability of the warp. Higher values lead to more pronounced warping.
knot int 4 The number of points in the cubic spline used for warping.

forward(self, x)

Applies non-linear time warping to the input data based on probability p.

Parameter Type Default Description
x - - (undocumented)

Returns: torch.Tensor (The input tensor with time warping applied (if applied)).

WindowSlice

augmentations.WindowSlice

The WindowSlice class implements a data augmentation technique where a slice of the input data is stretched to fill the entire length of the input. This technique is useful for training models to focus on local features of the data and can be found in literature such as: 'Time Series Data Augmentation for Deep Learning: A Survey' (https://halshs.archives-ouvertes.fr/halshs-01357973/document).

__init__(self, p, reduce_ratio=0.9)

Initializes the WindowSlice module.

Parameter Type Default Description
p - - The probability of applying the window slicing to the input data.
reduce_ratio float 0.9 Determines the size of the slice relative to the original data.

forward(self, x)

Applies window slicing and stretching to the input data based on probability p.

Parameter Type Default Description
x - - (undocumented)

Returns: torch.Tensor (The input tensor with window slicing applied (if applied)).

WindowWarp

augmentations.WindowWarp

The WindowWarp class implements a data augmentation technique where a segment (window) of the input data is selected and warped in size. This technique is useful for simulating variations in the speed or rate of the data within a certain window, as discussed in: 'Time Series Data Augmentation for Deep Learning: A Survey' (https://halshs.archives-ouvertes.fr/halshs-01357973/document).

__init__(self, p, window_ratio=0.1, scales=[0.5, 2.0])

Initializes the WindowWarp module.

Parameter Type Default Description
p - - The probability of applying the window warp to the input data.
window_ratio float 0.1 Determines the size of the window relative to the original data.
scales list [0.5, 2.0] The possible scaling factors to be applied to the window.

forward(self, x)

Applies window warping to the input data based on probability p.

Parameter Type Default Description
x - - (undocumented)

Returns: torch.Tensor (The input tensor with window warping applied (if applied)).