Skip to content
class

ChannelDropout

extendsPhotometricTransform[ChannelDropParams]
ChannelDropout(channel_drop_range: tuple[int, int] = (1, 1), fill_value: float = 0.0, p: float = 0.5)

Replace random channels with a constant fill value (Albumentations ChannelDropout).

Samples a count n uniformly from channel_drop_range and selects n distinct channels without replacement. Each chosen channel is replaced by fill_value via a multiplicative keep-mask

  • additive fill, so the op stays autograd-friendly.

Parameters

channel_drop_range(int, int)= (1, 1)
Inclusive range from which the number of channels to drop is sampled (randint(lo, hi + 1)).
fill_valuefloat= 0.0
Value written into the dropped channels.
pfloat= 0.5
Probability of applying the transform.

Examples

>>> import lucid
>>> import lucid.utils.transforms as T
>>> tf = T.ChannelDropout(channel_drop_range=(1, 1), fill_value=0.0, p=1.0)
>>> out = tf(T.Image(lucid.rand(3, 32, 32))).data
>>> tuple(out.shape)
(3, 32, 32)

Used by 1

Constructors

1
dunder

__init__

→None
__init__(channel_drop_range: tuple[int, int] = (1, 1), fill_value: float = 0.0, p: float = 0.5)

Instance methods

1
fn

make_params

→ChannelDropParams
make_params(img: Tensor)

Sample per-call random parameters for ChannelDropout.

Parameters

Image tensor; its channel-axis size is read so that the sample-without-replacement loop never returns duplicate or out-of-range indices.

Returns

ChannelDropParams

Carries channels — a tuple of distinct channel indices (sampled without replacement) to replace with fill_value in the apply step.

Notes

The number of dropped channels is drawn from channel_drop_range; it is clamped to the available channel count if the high bound exceeds C.

Dunder methods

1