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 it has no sign — a fold
is neither increasing nor decreasing.
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 ).
There is no log-determinant: the map folds the two half-lines onto one, so
it is not a bijection and log_abs_det_jacobian raises
NotImplementedError, as in the reference. Folding the sign halves
the density (composing with a Normal(0,1) base gives the half-Normal
, ), which the standard
change-of-variable formula cannot express.
Examples
>>> import lucid
>>> from lucid.distributions.transforms import AbsTransform
>>> T = AbsTransform()
>>> T(lucid.tensor(-3.0))
tensor(3.)