AlbumentationsExplore
DocumentationExploreAdoptionCommercial LicenseBlog
GitHub

ChannelDropout

Targets:
image
volume
Image Types:uint8, float16, float32

Replace a fraction of eligible channels with a fill value to model missing spectral bands or unavailable sensors while retaining at least one input channel.

Arguments
channels_to_drop
tuple[int, ...] | None

Unique, non-negative channel indices eligible for dropout. None makes every input channel eligible. An explicit sequence must be non-empty, and every index must exist in each image-like target. Default: None.

dropout_ratio
float
0.5

Fraction of eligible channels to replace, in [0, 1]. The count is rounded to the nearest integer using decimal half-up rounding, then capped at the total number of input channels minus one. Default: 0.5.

fill
float
0

Value assigned to the selected channels. Use a value in the input dtype's image range, such as 0 for missing signal. Positive and negative zero are equivalent; the sign of filled zeros is not guaranteed. Default: 0.

p
float
0.5

Probability of applying the transform, in [0, 1]. Default: 0.5.

Examples
>>> import numpy as np
>>> import albumentations as A
>>> image = np.ones((64, 96, 10), dtype=np.float32)
>>> transform = A.ChannelDropout(
...     channels_to_drop=(0, 2, 4, 6), dropout_ratio=0.5, p=1.0,
... )
>>> result = transform(image=image)["image"]
>>> assert np.count_nonzero(np.all(result == 0, axis=(0, 1))) == 2
>>> np.testing.assert_array_equal(result[..., (1, 3, 5, 7, 8, 9)], 1)
Notes
  • Channels are selected uniformly without replacement from the eligible set.
  • The fraction is measured against eligible channels, not all input channels. With four eligible channels, dropout_ratio=0.5 selects two of them.
  • At least one input channel is retained. A single-channel input is unchanged.
  • A zero ratio or a count rounded to zero leaves the input unchanged.
  • Targets with equal channel counts share the selected indices, including all frames in an image batch and all slices in a volume. Different channel counts receive separate selections.
  • Retained channel values are unchanged; no dropout rescaling is applied.
See Also
  • PixelDropout: Replace individual pixels instead of entire channels.
  • CoarseDropout: Replace rectangular spatial regions.