Skip to content
class

ReplayCompose

extends_Container
ReplayCompose(transforms: list[TransformLike], p: float = 1.0)

Compose that records applied params for deterministic replay.

After a call, replay_data holds (transform, params, applied) per child; replay re-applies the same params to a new sample (e.g. to apply an identical augmentation to a paired input).

Parameters

pfloat= 1.0
Probability of applying the transform; otherwise the input passes through unchanged.

Examples

Records what it sampled, so the same random transform can be applied
again — to a second view, or to a mask that arrived later:
>>> import lucid, lucid.utils.transforms as T
>>> tf = T.ReplayCompose([T.RandomCrop(16, 16), T.HorizontalFlip(p=0.5)])
>>> tuple(tf(T.Image(lucid.rand(3, 32, 32))).data.shape)
(3, 16, 16)

Used by 1

Constructors

2
dunder

__init__

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

__call__

→object
__call__(inputs: object)

Instance methods

2
fn

make_params

→Emptyfrom _NoParams
make_params(img: Tensor)
fn

replay

→object
replay(saved: list[tuple[TransformLike, object, bool]], inputs: object)

Re-apply a previously recorded replay_data to a new sample.

Walks the saved (transform, params, applied) log in order and dispatches each Transform with its original sampled params (no fresh sampling). Raw callables are re-invoked without parameters. Records marked applied=False are skipped, preserving the original gate decisions.

Parameters

savedlist of (TransformLike, object, bool)
Trace produced by an earlier __call__; usually other_compose.replay_data.
inputsobject
Sample to feed through the replayed pipeline.

Returns

object

The replayed output, structurally matching inputs.

Dunder methods

1