colout_batch#

composer.functional.colout_batch(sample, p_row=0.15, p_col=0.15, resize_target='auto')[source]#

Applies ColOut augmentation to a batch of images and (optionally) targets, dropping the same random rows and columns from all images and targets in a batch.

See the Method Card for more details.

Example

from composer.algorithms.colout import colout_batch
new_X = colout_batch(X_example, p_row=0.15, p_col=0.15)
Parameters
  • sample (Tensor | PIL.Image | Tuple[Tensor, Tensor] | Tuple[PIL.Image, PIL.Image]) โ€“ Either a single tensor or image or a 2-tuple of tensors or images. When tensor(s), the tensor must be of shape CHW for a single image or NCHW for a batch of images of shape.

  • p_row (float, optional) โ€“ Fraction of rows to drop (drop along H). Default: 0.15.

  • p_col (float, optional) โ€“ Fraction of columns to drop (drop along W). Default: 0.15.

  • resize_target (bool | str, optional) โ€“ If sample is a tuple, whether to resize both objects in the tuple. If set to 'auto', both objects will be resized if they have the same spatial dimensions. Otherwise, only the first object is resized. Default: 'auto'.

Returns

torch.Tensor | PIL.Image | Tuple[torch.Tensor, torch.Tensor] | Tuple[PIL.Image, PIL.Image] โ€“ A smaller image or 2-tuple of images with random rows and columns dropped.