BatchMixUp#

class torchaug.batch_transforms.BatchMixUp(alpha, inplace=False)[source]#

Mix input tensor with linear interpolation drawn according a Beta law.

The shape of the tensors is expected to be [B, …] with … any number of dimensions. The tensor should be float.

Note

The tensor is rolled according its first dimension and mixed with one drawn interpolation parameter per element in first dimension.

Parameters:
  • alpha (float) – Parameter for the Beta law.

  • inplace (bool, optional) – Whether to perform the operation inplace.

    Default: False

forward(tensor, labels=None)[source]#

Mix the input tensor and labels.

Parameters:
  • tensor (Tensor) – The tensor to mix.

  • labels (Optional[Tensor], optional) – If not None, the labels to mix.

    Default: None

Returns:

  • mixed tensor.

  • mixed labels or None.

  • mixing coefficients.

Return type:

Tuple