OrderedT#

class brainstate.nn.OrderedT#

Transformation ensuring ordered (monotonically increasing) output.

Maps unconstrained ℝⁿ to ordered vectors where y₁ < y₂ < … < yₙ. This is useful for parameters that must maintain an ordering constraint, such as cutpoints in ordinal regression.

The transformation is defined by:

\[\begin{split}y_1 = x_1 \\ y_i = y_{i-1} + \text{softplus}(x_i) \quad \text{for } i > 1\end{split}\]

The inverse transformation reverses this process.

Examples

>>> transform = OrderedT()
>>> x = jnp.array([0.0, 1.0, 0.5])
>>> y = transform.forward(x)
>>> # y is monotonically increasing
>>> assert jnp.all(jnp.diff(y) > 0)
forward(x)[source]#

Transform unconstrained input to ordered vectors.

Return type:

Array

inverse(y)[source]#

Transform ordered vectors back to unconstrained domain.

Return type:

Array