PositiveT#
- class brainstate.nn.PositiveT#
Transformation constraining parameters to be strictly positive (0, +∞).
This is a convenience class that provides a simple positive constraint using the exponential transformation with lower bound of 0.
The transformation is defined by:
\[\text{forward}(x) = e^x\]The inverse transformation is:
\[\text{inverse}(y) = \log(y)\]Notes
Important
forwardusessave_exp(), which clips the exponent atmax_value=20. Inputs withx > 20saturate atexp(20) ≈ 4.85e8and the transform is not invertible there; the analyticlog_abs_det_jacobian(sum(x)) is only valid in the unclipped region. Keep inputs within roughly[-20, 20].Examples
>>> transform = PositiveT() >>> x = jnp.array([-1.0, 0.0, 1.0]) >>> y = transform.forward(x) >>> # y ≈ [0.368, 1.0, 2.718]