mindspore.dataset.vision.c_transforms.CutMixBatch

class mindspore.dataset.vision.c_transforms.CutMixBatch(image_batch_format, alpha=1.0, prob=1.0)[source]

Apply CutMix transformation on input batch of images and labels. Note that you need to make labels into one-hot format and batch before calling this function.

Parameters
  • image_batch_format (Image Batch Format) – The method of padding. Can be any of [ImageBatchFormat.NHWC, ImageBatchFormat.NCHW]

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

  • prob (float, optional) – The probability by which CutMix is applied to each image (default = 1.0).

Examples

>>> import mindspore.dataset.transforms.c_transforms as c_transforms
>>> import mindspore.dataset.vision.c_transforms as c_vision
>>> from mindspore.dataset.transforms.vision import ImageBatchFormat
>>>
>>> onehot_op = c_transforms.OneHot(num_classes=10)
>>> data1 = data1.map(operations=onehot_op, input_columns=["label"])
>>> cutmix_batch_op = c_vision.CutMixBatch(ImageBatchFormat.NHWC, 1.0, 0.5)
>>> data1 = data1.batch(5)
>>> data1 = data1.map(operations=cutmix_batch_op, input_columns=["image", "label"])