Skip to content
class

ChannelShuffle

extendsPhotometricTransform[PermParams]
ChannelShuffle(p: float = 0.5)

Randomly permute the RGB channel order (Albumentations ChannelShuffle).

Samples a uniformly random permutation of (0, 1, 2) via a Fisher-Yates shuffle, then reorders the channel axis accordingly. No pixel arithmetic is performed — the operation is a pure slice + concat, so it composes cleanly with autograd.

Parameters

pfloat= 0.5
Probability of applying the transform.

Raises

ValueError
If the input image does not have exactly 3 channels.

Examples

>>> import lucid
>>> import lucid.utils.transforms as T
>>> tf = T.ChannelShuffle(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__(p: float = 0.5)

Instance methods

1
fn

make_params

→PermParams
make_params(img: Tensor)

Sample per-call random parameters for ChannelShuffle.

Parameters

Image tensor; not inspected, carried through for dispatch.

Returns

PermParams

Carries order — a uniformly-random permutation of (0, 1, 2) produced by a Fisher-Yates shuffle.

Dunder methods

1