AffineTransform
TransformAffineTransform(loc: Tensor | float, scale: Tensor | float, event_dim: int = 0)Element-wise affine bijection .
The fundamental location-scale transform. Composing with a
standard Normal yields ; it underpins virtually every reparameterised
sampler in the codebase. Bijective, with sign that of scale
(+1, 0 or -1 for a number; the element-wise sign tensor for
a tensor).
Parameters
Notes
Forward: .
Inverse: .
Log Jacobian determinant (broadcast to x.shape):
For element-wise application (event_dim = 0) this is summed by
IndependentTransform if the caller reinterprets trailing
dims as event dims.
Examples
>>> import lucid
>>> from lucid.distributions.transforms import AffineTransform
>>> T = AffineTransform(loc=1.0, scale=2.0)
>>> T(lucid.tensor(3.0))
tensor(7.)Used by 2
Constructors
1Properties
3real for scalar events, or independent(real, event_dim).
real for scalar events, or independent(real, event_dim).
Sign of scale: 1 / 0 / -1 for a number, else the sign tensor.
Instance methods
1Constant log-Jacobian .
The Jacobian of
is just scale, so the log-determinant is constant in x.
We add zeros_like(x) so the result broadcasts to x's
full shape (callers expect element-wise log-Jacobians).
Parameters
Returns
Tensorlog|scale| broadcast to x.shape and summed over event_dim.