mindspore.dataset.vision.c_transforms.MixUpBatch

class mindspore.dataset.vision.c_transforms.MixUpBatch(alpha=1.0)[source]

Apply MixUp transformation on input batch of images and labels. Each image is multiplied by a random weight (lambda) and then added to a randomly selected image from the batch multiplied by (1 - lambda). The same formula is also applied to the one-hot labels. Note that you need to make labels into one-hot format and batch before calling this function.

Parameters

alpha (float, optional) – Hyperparameter of beta distribution (default = 1.0).

Examples

>>> import mindspore.dataset.transforms.c_transforms as c_transforms
>>> import mindspore.dataset.vision.c_transforms as c_vision
>>>
>>> onehot_op = c_transforms.OneHot(num_classes=10)
>>> data1 = data1.map(operations=onehot_op, input_columns=["label"])
>>> mixup_batch_op = c_vision.MixUpBatch(alpha=0.9)
>>> data1 = data1.batch(5)
>>> data1 = data1.map(operations=mixup_batch_op, input_columns=["image", "label"])