SoftsignT#

class brainstate.nn.SoftsignT(lower, upper)#

Softsign-based transformation mapping (-inf, +inf) to (lower, upper).

y = lower + width * (x / (1 + |x|) + 1) / 2 x = z / (1 - |z|), where z = 2 * (y - lower) / width - 1, z in (-1, 1)

forward(x)[source]#

Apply the forward transformation.

Transforms input from the unconstrained domain to the constrained domain. This method implements the mathematical function \(y = f(x)\) where \(x\) is in the unconstrained space and \(y\) is in the target domain.

Parameters:

x (Array | ndarray | bool | number | bool | int | float | complex | Quantity) – Input array in the unconstrained domain.

Returns:

Transformed output in the constrained domain.

Return type:

Array

Notes

Implementations must ensure numerical stability and handle boundary conditions appropriately.

inverse(y)[source]#

Apply the inverse transformation.

Transforms input from the constrained domain back to the unconstrained domain. This method implements the mathematical function \(x = f^{-1}(y)\) where \(y\) is in the constrained space and \(x\) is in the unconstrained domain.

Parameters:

y (Array | ndarray | bool | number | bool | int | float | complex | Quantity) – Input array in the constrained domain.

Returns:

Transformed output in the unconstrained domain.

Return type:

Array

Notes

Implementations must ensure that inverse(forward(x)) = x for all valid x, and forward(inverse(y)) = y for all y in the target domain.