mindspore.dataset.vision.py_transforms.Cutout

class mindspore.dataset.vision.py_transforms.Cutout(length, num_patches=1)[source]

Randomly cut (mask) out a given number of square patches from the input NumPy image array of shape (C, H, W).

Terrance DeVries and Graham W. Taylor ‘Improved Regularization of Convolutional Neural Networks with Cutout’ 2017 See https://arxiv.org/pdf/1708.04552.pdf

Parameters
  • length (int) – The side length of each square patch.

  • num_patches (int, optional) – Number of patches to be cut out of an image (default=1).

Examples

>>> from mindspore.dataset.transforms.py_transforms import Compose
>>> transforms_list = Compose([py_vision.Decode(),
...                            py_vision.ToTensor(),
...                            py_vision.Cutout(80)])
>>> # apply the transform to dataset through map function
>>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list,
...                                                 input_columns="image")