Parameter Containers

Parameter Containers#

Flexible parameter containers that integrate with BrainState’s module system. Param supports bijective transformations for constrained optimization and optional regularization. Const provides non-trainable constant parameters. Both support automatic caching of transformed values for improved performance.

Param

A module has neural network parameters for optional transform and regularization.

Const

A module has non-trainable constant parameter.

Parameter Transforms#

Bijective transformations for constrained parameter optimization. These transforms map between unconstrained and constrained spaces, enabling gradient-based optimization of parameters with constraints (positivity, boundedness, simplex, etc.). All transforms implement forward(), inverse(), and optional log_abs_det_jacobian() for probabilistic applications. Use with Param for automatic constraint handling.

Transform

Abstract base class for bijective parameter transformations.

IdentityT

Identity transformation (no-op).

ClipT

Transformation with clipping to specified bounds.

AffineT

Affine (linear) transformation with scaling and shifting.

SigmoidT

Sigmoid transformation mapping unbounded values to a bounded interval.

TanhT

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

SoftsignT

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

ScaledSigmoidT

Sigmoid transformation with adjustable sharpness/temperature.

SoftplusT

Softplus transformation mapping unbounded values to positive semi-infinite interval.

NegSoftplusT

Negative softplus transformation mapping unbounded values to negative semi-infinite interval.

LogT

Log transformation mapping (lower, +inf) to (-inf, +inf).

ExpT

Exponential transformation mapping (-inf, +inf) to (lower, +inf).

ReluT

ReLU transform with lower bound: forward(x) = relu(x) + lower_bound

PositiveT

Transformation constraining parameters to be strictly positive (0, +∞).

NegativeT

Transformation constraining parameters to be strictly negative (-∞, 0).

PowerT

Power (Box-Cox) transformation for stabilizing variance.

OrderedT

Transformation ensuring ordered (monotonically increasing) output.

SimplexT

Stick-breaking transformation for simplex constraint.

UnitVectorT

Transformation to unit vectors (L2 norm = 1).

ChainT

Composition of multiple transformations applied sequentially.

MaskedT

Selective transformation using a boolean mask.