class
AffineTransform
extends
TransformAffineTransform(loc: Tensor | float, scale: Tensor | float)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 matching
sign(scale); the implementation fixes self.sign = +1, so the
caller is responsible for ensuring scale > 0.
Parameters
locTensor or floatAdditive offset .
scaleTensor or floatMultiplicative slope (assumed positive).
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.0)Methods (2)
dunder
__init__
→None__init__(loc: Tensor | float, scale: Tensor | float)Store the affine offset loc and multiplier scale.
The caller is responsible for ensuring scale > 0; sign is
fixed at +1 here so the transform is treated as increasing.
fn
log_abs_det_jacobian
→Tensorlog_abs_det_jacobian(x: Tensor, y: Tensor)Constant log-Jacobian , broadcast to x's shape.