Skip to content
class

OneOrOther

extends_Container
OneOrOther(first: TransformLike, second: TransformLike, p: float = 0.5)

Apply first with probability p else second (Albumentations OneOrOther).

A two-way categorical: every call invokes either first or second, never both, never neither. The selected child is forced to run with its own probability gate bypassed — p here is the switch between the two branches, not a skip-probability, so the container has effective probability 1.

Parameters

firstTransformLike
Child invoked when the per-call uniform sample is below p.
secondTransformLike
Child invoked otherwise.
pfloat= 0.5
Switch probability; 0.5 gives the two branches equal odds.

Examples

>>> import lucid.utils.transforms as T
>>> tf = T.OneOrOther(
...     first=T.HorizontalFlip(p=1.0),
...     second=T.VerticalFlip(p=1.0),
...     p=0.7,
... )

Used by 1

Constructors

2
dunder

__init__

→None
__init__(first: TransformLike, second: 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