src.utils.ptransf.simple_data_augmentor

Classes

SimpleDataAugmentor(**kwargs)

class src.utils.ptransf.simple_data_augmentor.SimpleDataAugmentor(**kwargs)
Author:

Alberto M. Esmoris Pena

Class representing a simple data augmentation object. It supports random rotations, scaling, and jitter. Each data augmentation transformation can be defined with a random distribution that can be either normal or uniform.

Variables:

transformations (list of dict) – List of transformations to be applied to augment the input data.

__init__(**kwargs)

Initialize the simple data augmentor.

Parameters:

kwargs – The key-word specification for the initialization of the simple data augmentor.

augment(X, **kwargs)

See DataAugmentor and DataAugmentor.augment().

Parameters:

X (list or np.ndarray) – It can be a single batch, e.g., a tensor \(K x m x n\) that represents \(K\) point clouds of \(m\) points in a \(n\)-dimensional space. Alternatively, it can be a list of batch elements, such that all the elements in the list must be consistently augmented. For example, assume [X1, X2, X3] is given where \(\mathcal{X}_i \in \mathbb{R}^{K_i \times m_i \times n}\) for \(i=1,\ldots,3\). Then the matrices \(\pmb{X}_{1j}\), \(\pmb{X}_{2j}\), and \(\pmb{X}_{3j}\) must be augmented in the same way, i.e., using the same samples from random distributions, for rotations and scaling. However, jitter will be applied independently to any element.

static apply_transformation(transformation, X)

Apply the given transformation to the structure space matrices.

NOTE that the transformation is applied in place, despite the transformed space is also returned.

Parameters:
  • transformation (dict) – The specification of the transformation to be applied.

  • X (list or np.ndarray) – The structure spaces to be transformed.

Returns:

The transformed structure spaces.

Return type:

list or np.ndarray

static apply_rotation(transformation, X)

Apply a rotation transformation.

Parameters:
  • transformation (dict) – The rotation specification.

  • X (list or np.ndarray) – The structure spaces to be transformed.

Returns:

The rotated structure spaces.

Return type:

list or np.ndarray

static apply_scale(transformation, X)

Apply a scaling transformation.

Parameters:
  • transformation – The scaling specification.

  • X (list or np.ndarray) – The structure spaces to be transformed.

Returns:

The scaled structure spaces.

Return type:

list or np.ndarray

static apply_jitter(transformation, X)

Apply a jitter transformation.

Parameters:
  • transformation – The jitter specification.

  • X (list or np.ndarray) – The structure spaces to be transformed.

Returns:

The structure spaces with jitter.

Return type:

list or np.ndarray

static compute_distribution(distribution, dim=1)

Compute the distribution corresponding to the given specification.

Parameters:
  • distribution (dict) – The specification of the distribution to be computed.

  • dim – The sampling dimensionality, i.e., how many samples will be taken from the distribution.

Returns:

A tensor of samples representing the computed distribution.

Return type:

np.ndarray

static set_rotation_matrix(R, axis, angle)
Update the rotation matrix in place, so it represents a rotation

around the given axis with the given angle.

Parameters:
  • R (np.ndarray) – The rotation matrix to be updated.

  • axis (list or tuple or np.ndarray) – The rotation axis.

  • angle – The angle of the rotation.

Typa angle:

float

Returns:

The updated rotation matrix (it is also updated in place).

Return type:

np.ndarray