Skip to content
class

PixelDropout

extendsPhotometricTransform[PixelMaskParams]
PixelDropout(dropout_prob: float = 0.01, per_channel: bool = False, drop_value: float = 0.0, p: float = 0.5)

Randomly set individual pixels to a fill value (Albumentations PixelDropout).

Samples a per-pixel Bernoulli mask with drop probability dropout_prob and replaces masked pixels with drop_value using a multiplicative keep-mask + additive fill (autograd-friendly, no in-place writes). When per_channel=True the mask is sampled independently for each channel; otherwise a single mask is broadcast across channels.

Parameters

dropout_probfloat= 0.01
Independent per-pixel drop probability.
per_channelbool= False
If True, sample the dropout mask independently per channel. If False, a single mask is shared across channels so dropped pixels go to the fill value in all channels at once.
drop_valuefloat= 0.0
Value written into dropped pixels.
pfloat= 0.5
Probability of applying the transform.

Examples

>>> import lucid
>>> import lucid.utils.transforms as T
>>> tf = T.PixelDropout(dropout_prob=0.05, per_channel=False, 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__(dropout_prob: float = 0.01, per_channel: bool = False, drop_value: float = 0.0, p: float = 0.5)

Instance methods

1
fn

make_params

→PixelMaskParams
make_params(img: Tensor)

Sample per-call random parameters for PixelDropout.

Parameters

Image tensor; its channel count and spatial size are read to size the Bernoulli keep-mask.

Returns

PixelMaskParams

Carries mask — a per-pixel keep mask of shape (C, H, W) (when per_channel=True) or (1, H, W) (otherwise), with each entry independently 1 with probability 1 - dropout_prob.

Dunder methods

1