- class composer.algorithms.CutOut(num_holes=1, length=0.5, uniform_sampling=False, input_key=0)#
CutOut is a data augmentation technique that works by masking out one or more square regions of an input image.
This implementation cuts out the same square from all images in a batch.
from composer.algorithms import CutOut from composer.trainer import Trainer cutout_algorithm = CutOut(num_holes=1, length=0.25) trainer = Trainer( model=model, train_dataloader=train_dataloader, eval_dataloader=eval_dataloader, max_duration="1ep", algorithms=[cutout_algorithm], optimizers=[optimizer] )
num_holes (int, optional) – Integer number of holes to cut out. Default:
length (float, optional) – Relative side length of the masked region. If specified,
lengthis interpreted as a fraction of
W, and the resulting box is a square with side length
length * min(H, W). Must be in the interval \((0, 1)\). Default:
uniform_sampling (bool, optional) – If
True, sample the bounding box such that each pixel has an equal probability of being masked. If
False, defaults to the sampling used in the original paper implementation. Default:
input_key (str | int | Tuple[Callable, Callable] | Any, optional) – A key that indexes to the input from the batch. Can also be a pair of get and set functions, where the getter is assumed to be first in the pair. The default is 0, which corresponds to any sequence, where the first element is the input. Default: