composer.algorithms.colout.colout#
Core ColOut classes and functions.
Functions
Applies ColOut augmentation to a batch of images, dropping the same random rows and columns from all images in a batch. |
Classes
Drops a fraction of the rows and columns of an input image. |
|
Torchvision-like transform for performing the ColOut augmentation, where random rows and columns are dropped from a single image. |
- class composer.algorithms.colout.colout.ColOut(p_row=0.15, p_col=0.15, batch=True)[source]#
Bases:
composer.core.algorithm.AlgorithmDrops a fraction of the rows and columns of an input image. If the fraction of rows/columns dropped isnโt too large, this does not significantly alter the content of the image, but reduces its size and provides extra variability.
If
batchis True (the default), this algorithm runs onEvent.INITto insert a dataset transformation. It is a no-op if this algorithm already applied itself on theState.train_dataloader.dataset.Otherwise, if
batchis False, then this algorithm runs onEvent.AFTER_DATALOADERto modify the batch.See the Method Card for more details.
Example
from composer.algorithms import ColOut from composer.trainer import Trainer colout_algorithm = ColOut(p_row=0.15, p_col=0.15, batch=True) trainer = Trainer( model=model, train_dataloader=train_dataloader, eval_dataloader=eval_dataloader, max_duration="1ep", algorithms=[colout_algorithm], optimizers=[optimizer] )
- class composer.algorithms.colout.colout.ColOutTransform(p_row=0.15, p_col=0.15)[source]#
Torchvision-like transform for performing the ColOut augmentation, where random rows and columns are dropped from a single image.
See the Method Card for more details.
Example
from torchvision import datasets, transforms from composer.algorithms.colout import ColOutTransform colout_transform = ColOutTransform(p_row=0.15, p_col=0.15) transforms = transforms.Compose([colout_transform, transforms.ToTensor()])
- composer.algorithms.colout.colout.colout_batch(input, p_row=0.15, p_col=0.15)[source]#
Applies ColOut augmentation to a batch of images, dropping the same random rows and columns from all images 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
input โ
PIL.Image.Imageortorch.Tensorof image data. In the latter case, must be a single image of shapeCHWor a batch of images of shapeNCHW.p_row โ Fraction of rows to drop (drop along H). Default:
0.15.p_col โ Fraction of columns to drop (drop along W). Default:
0.15.
- Returns
torch.Tensor โ Input batch tensor with randomly dropped columns and rows.