mindspore.dataset.vision.CutMixBatch
- class mindspore.dataset.vision.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 batched before calling this operation.
- Parameters
image_batch_format (ImageBatchFormat) – The method of padding. Can be any of [ImageBatchFormat.NHWC, ImageBatchFormat.NCHW].
alpha (float, optional) – Hyperparameter of beta distribution, must be larger than 0. Default:
1.0
.prob (float, optional) – The probability by which CutMix is applied to each image, which must be in range: [0.0, 1.0]. Default:
1.0
.
- Raises
TypeError – If image_batch_format is not of type
mindspore.dataset.vision.ImageBatchFormat
.TypeError – If alpha is not of type float.
TypeError – If prob is not of type float.
ValueError – If alpha is less than or equal 0.
ValueError – If prob is not in range [0.0, 1.0].
RuntimeError – If given tensor shape is not <H, W, C>.
- Supported Platforms:
CPU
Examples
>>> import mindspore.dataset as ds >>> import mindspore.dataset.vision as vision >>> import mindspore.dataset.transforms as transforms >>> from mindspore.dataset.vision import ImageBatchFormat >>> >>> image_folder_dataset = ds.ImageFolderDataset("/path/to/image_folder_dataset_directory") >>> onehot_op = transforms.OneHot(num_classes=10) >>> image_folder_dataset= image_folder_dataset.map(operations=onehot_op, ... input_columns=["label"]) >>> cutmix_batch_op = vision.CutMixBatch(ImageBatchFormat.NHWC, 1.0, 0.5) >>> image_folder_dataset = image_folder_dataset.batch(5) >>> image_folder_dataset = image_folder_dataset.map(operations=cutmix_batch_op, ... input_columns=["image", "label"])
- Tutorial Examples: