minerva.transforms.tfc

Classes

TFC_Transforms

Transformations used in the TFC model.

Module Contents

class minerva.transforms.tfc.TFC_Transforms[source]

Bases: minerva.transforms.transform._Transform

Transformations used in the TFC model. It consists of time and frequency domain data augmentation.

DataTransform_FD(sample)[source]

Weak and strong augmentations. Consists of jittering and adding or removing frequency components.

Parameters

  • sample: np.ndarray

    The input data to be augmented

Returns

  • np.ndarray

    The augmented data

Parameters:

sample (numpy.ndarray)

Return type:

numpy.ndarray

DataTransform_TD(sample, jitter_ratio=0.8)[source]

Weak and strong augmentations. Consists of jittering and removing time components.

Parameters

  • sample: np.ndarray

    The input data to be augmented

  • jitter_ratio: float

    The ratio of the jittering transformation

Returns

  • np.ndarray

    The augmented data

Parameters:
  • sample (numpy.ndarray)

  • jitter_ratio (float)

Return type:

numpy.ndarray

__call__(x)[source]

Method that applies the transformations to the input data.

Parameters

  • x: Union[np.ndarray, torch.Tensor]

    The input data to be transformed

Returns

  • Tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor]

    A tuple with the original data, the transformed data in the time domain the frequency version of the data and the tranformed data in frequency domain

Parameters:

x (Union[numpy.ndarray, torch.Tensor])

Return type:

Tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor]

add_frequency(x, pertub_ratio=0)[source]

function to add frequency components to the input data.

Parameters

  • x: np.ndarray

    The input data to be augmented

  • pertub_ratio: float

    The ratio of the frequency components to be added

Returns

  • np.ndarray

    The data with added frequency components

Parameters:
  • x (numpy.ndarray)

  • pertub_ratio (float)

jitter(x, sigma=0.8)[source]

Add noise to the input data.

Parameters

  • x: np.ndarray

    The input data to be augmented

  • sigma: float

    The standard deviation of the noise

Returns

  • np.ndarray

    The data with added noise

Parameters:
  • x (numpy.ndarray)

  • sigma (float)

one_hot_encoding(X, n_values=None)[source]

One-hot encoding of the input data

Parameters

  • X: np.ndarray

    The input data to be encoded

  • n_values: int

    The number of classes in the data. If None, the number of classes is inferred from the data

Returns

  • np.ndarray

    The one-hot encoded data

Parameters:
  • X (numpy.ndarray)

  • n_values (int)

remove_frequency(x, maskout_ratio=0)[source]

function to remove frequency components from the input data.

Parameters

  • x: np.ndarray

    The input data to be augmented

  • maskout_ratio: float

    The ratio of the frequency components to be removed

Returns

  • np.ndarray

    The data with removed frequency components

Parameters:
  • x (numpy.ndarray)

  • maskout_ratio (float)