Const

Contents

Const#

class brainstate.nn.Const(value, **param_kwargs)[source]#

A module has non-trainable constant parameter.

A convenience class that creates a fixed (non-trainable) parameter. Equivalent to Param(value, fit=False).

“Non-trainable” means the value is not wrapped in a trainable ParamState and is therefore excluded from gradient-based optimization. It does not mean the value is immutable: it can still be updated explicitly via set_value() or clip().

Parameters:

value (Array | ndarray | bool | number | bool | int | float | complex | Quantity) – The constant value.

Examples

>>> import jax.numpy as jnp
>>> from brainstate.nn import Const
>>> const = Const(jnp.array([1.0, 2.0]))
>>> const.value()