ComposeTransform
TransformComposeTransform(parts: list[Transform])Function composition of a list of transforms — left-to-right.
Implements the composite map
so that the
first transform in parts is applied first. The composite
Jacobian is the sum of the per-step Jacobians along the trajectory,
by the chain rule. This is the workhorse for stacking normalising
flows.
Parameters
partslist[Transform]event_dim values are reduced via max.Raises
ValueErrorparts is empty.Notes
Forward:
Inverse (transforms run in reverse with each one inverted):
Log Jacobian determinant (chain rule):
where and . The implementation re-evaluates the forward chain to collect the intermediate states needed by each sub-Jacobian.
Examples
>>> import lucid
>>> from lucid.distributions.transforms import (
... ExpTransform, AffineTransform, ComposeTransform)
>>> # Log-normal-like: y = exp(loc + scale * x)
>>> T = ComposeTransform([AffineTransform(loc=0.0, scale=1.0), ExpTransform()])
>>> T(lucid.tensor(0.0))
Tensor(1.0)Methods (2)
__init__
→None__init__(parts: list[Transform])Store the ordered list of sub-transforms.
Raises
ValueErrorparts is empty.log_abs_det_jacobian
→Tensorlog_abs_det_jacobian(x: Tensor, y: Tensor)Cumulative log-Jacobian across the composition.
Re-evaluates the chain of forward maps to obtain the intermediate states needed by each sub-Jacobian, then sums the contributions.