Abstract bijection between two measurable spaces.
A Transform represents an invertible map
together with its
log-absolute-determinant Jacobian, used to push a base distribution
through a measurable bijection. Composed with a base distribution
via TransformedDistribution, it implements normalising flows,
coupling layers, and standard change-of-variable arguments.
The change-of-variable formula for densities is
so the per-transform Jacobian determinant must be tractable.
Subclasses must override:
_call— forward map ._inverse— inverse map .log_abs_det_jacobian— , broadcast over the batch dimensions of the input.
Attributes
bijectiveboolTrue if the transform is invertible (most are; notable
exception: AbsTransform).signintevent_dimint0 for element-wise maps,
for vector / matrix transforms (e.g.
SoftmaxTransform has event_dim = 1,
LowerCholeskyTransform has event_dim = 2).Notes
Composition and inversion are provided structurally:
ComposeTransform— .~transform/inv— lazy_InverseTransformview.
so users can build complex bijectors without manually tracking Jacobian terms.
Examples
>>> import lucid
>>> from lucid.distributions.transforms import ExpTransform, AffineTransform, ComposeTransform
>>> # y = exp(2*x + 1) — a log-normal-like transform
>>> T = ComposeTransform([AffineTransform(loc=1.0, scale=2.0), ExpTransform()])
>>> x = lucid.tensor(0.0)
>>> y = T(x)
>>> T.log_abs_det_jacobian(x, y)
Tensor(...)Used by 1
Constructors
2Properties
1Instance methods
1Log-absolute-determinant of the Jacobian .
Subclasses must override and return broadcast over the input batch dimensions.
Parameters
Returns
TensorElement-wise log-absolute-Jacobian-determinant, broadcastable
to x.shape.