cerebras.modelzoo.data.vision.classification.mixup.RandomMixup#

class cerebras.modelzoo.data.vision.classification.mixup.RandomMixup(*args, **kwargs)[source]#

Bases: torch.nn.Module

Randomly apply Mixup to the provided batch and targets. The class implements the data augmentations as described in the paper “mixup: Beyond Empirical Risk Minimization”. :param num_classes: number of classes used for one-hot encoding. :type num_classes: int :param p: probability of the batch being transformed. Default value is 0.5. :type p: float :param alpha: hyperparameter of the Beta distribution used for mixup.

Default value is 1.0.

Parameters

inplace (bool) – boolean to make this transform inplace. Default set to False.

Methods

forward

param batch

Float tensor of size (B, C, H, W)

forward(batch, target)[source]#
Parameters
  • batch (Tensor) – Float tensor of size (B, C, H, W)

  • target (Tensor) – Integer tensor of size (B, )

Returns

Randomly transformed batch.

Return type

Tensor