AbsTransform
TransformAbsTransform()Element-wise absolute value (folded, not bijective).
Maps element-wise by folding the
sign. Useful when composing with symmetric base distributions
(e.g. a Normal) to produce a half-Normal or folded-Normal
pushforward. bijective = False and sign = +1.
Because both and map to the same , the transform is non-invertible. The pseudo-inverse used here is the identity, under the convention that the preimage is assumed to lie on the non-negative half-line.
Notes
Forward: .
Pseudo-inverse: (assumes ).
Log Jacobian determinant:
everywhere off the measure-zero set where the map is non-differentiable.
Folding the sign halves the density: composing with a Normal(0,1)
base gives the half-Normal density for
, which requires special handling outside the
standard change-of-variable formula. Lucid's
TransformedDistribution does not currently correct for
this folding factor — apply the constant manually
when needed.
Examples
>>> import lucid
>>> from lucid.distributions.transforms import AbsTransform
>>> T = AbsTransform()
>>> T(lucid.tensor(-3.0))
Tensor(3.0)Methods (1)
log_abs_det_jacobian
→Tensorlog_abs_det_jacobian(x: Tensor, y: Tensor)Zero everywhere — outside the kink at zero.