Skip to content
class

OneOf

extends_Container
OneOf(transforms: list[TransformLike], p: float = 0.5)

Apply exactly one child, sampled by child-p weight (Albumentations OneOf).

On each call (gated by the container's p), draws a single child via a categorical distribution whose weights are the children's own p values normalised to sum to 1. The selected child is then forced to run with its own probability gate bypassed — its p acts purely as a selection weight, not a per-call skip-probability. Equal weights ⇒ uniform sampling.

Parameters

transformslist of TransformLike
Candidate children. Each child's p is used as its unnormalised selection weight; raw callables get weight 1.
pfloat= 0.5
Container-level gate — with probability 1 - p the entire block is skipped and the input passes through unchanged.

Examples

>>> import lucid.utils.transforms as T
>>> tf = T.OneOf([
...     T.HorizontalFlip(p=1.0),
...     T.VerticalFlip(p=1.0),
... ], p=1.0)

Used by 1

Constructors

2
dunder

__init__

→None
__init__(transforms: list[TransformLike], p: float = 0.5)
dunder

__call__

→object
__call__(inputs: object)

Instance methods

1
fn

make_params

→Emptyfrom _NoParams
make_params(img: Tensor)

Dunder methods

1