ColOut#

class composer.algorithms.ColOut(p_row=0.15, p_col=0.15, batch=True, resize_target='auto', input_key=0, target_key=1)[source]#

Drops a fraction of the rows and columns of an input image and (optionally) a target 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 batch is True (the default), then this algorithm runs on Event.AFTER_DATALOADER to modify the batch.

Otherwise, if batch=False (the default), this algorithm runs on Event.INIT to insert a dataset transformation. It is a no-op if this algorithm already applied itself on the State.train_dataloader.dataset.

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]
)
Parameters
  • 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.

  • batch (bool, optional) โ€“ Run ColOut at the batch level. Default: True.

  • resize_target (bool | str, optional) โ€“ Whether to resize the target in addition to the input. If set to 'auto', resizing the target will be based on if the target has the same spatial dimensions as the input. Default: auto.

  • 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: 0.

  • target_key (str | int | Tuple[Callable, Callable] | Any, optional) โ€“ A key that indexes to the target 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 1, which corresponds to any sequence, where the second element is the target. Default: 1.