modelzoo.vision.pytorch.input.classification.mixup.RandomMixup#

class modelzoo.vision.pytorch.input.classification.mixup.RandomMixup[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)

__call__(*args: Any, **kwargs: Any) Any#

Call self as a function.

__init__(num_classes, p=0.5, alpha=1.0, inplace=False)[source]#
static __new__(cls, *args: Any, **kwargs: Any) Any#
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