IndependentTransform
TransformIndependentTransform(transform: Transform, reinterpreted_batch_ndims: int)Reinterpret n trailing batch dimensions of an inner transform as event dims.
A thin wrapper that does not modify the forward / inverse maps but
changes how the log-Jacobian-determinant is aggregated: the inner
transform's per-element is summed over the
reinterpreted trailing axes, producing a joint event Jacobian
instead of an element-wise one. This is the bijection analogue of
lucid.distributions.Independent for distributions.
Parameters
transformTransformreinterpreted_batch_ndimsintNotes
Forward / inverse: unchanged from the inner transform.
Log Jacobian determinant (with =
reinterpreted_batch_ndims minus the inner event_dim):
Use this whenever an element-wise transform (e.g. ExpTransform)
is applied to a vector that you want treated as a single event for the
purposes of computing under the pushforward
distribution.
Examples
>>> import lucid
>>> from lucid.distributions.transforms import ExpTransform, IndependentTransform
>>> T = IndependentTransform(ExpTransform(), reinterpreted_batch_ndims=1)
>>> T(lucid.tensor([0.0, 1.0, 2.0]))
Tensor([1.0, 2.7183, 7.3891])Methods (2)
__init__
→None__init__(transform: Transform, reinterpreted_batch_ndims: int)Wrap transform and promote reinterpreted_batch_ndims batch dims to event dims.
log_abs_det_jacobian
→Tensorlog_abs_det_jacobian(x: Tensor, y: Tensor)Sum the wrapped Jacobian over the reinterpreted trailing dims.