parameters.State
- class parameters.State(data: ~typing.Any | None = None, family: str | None = None, init_func: ~typing.Callable[[~typing.Any], ~typing.Any] | None = None, shape: ~typing.List[~typing.Tuple] | ~typing.Tuple | int | None = None, permit_reshape: bool = True, cast_fn: ~typing.Callable[[~typing.Any], ~typing.Any] = <function ParameterBase.<lambda>>)[source]
Bases:
ParameterBase
Represent a module state
A
State
in Rockpool is a transient value which is required to maintain the dynamics of a stateful module. For example the membrane potential of a neuron; the synaptic current; the refractory state of a neuron; etc.See also
See
Parameter
for representing the configuration of a module, andSimulationParameter
for representing simulation- or solver-specific parameters that are not important for network configuration.Methods overview
__init__
([data, family, init_func, shape, ...])Instantiate a Rockpool registered attribute
- __init__(data: ~typing.Any | None = None, family: str | None = None, init_func: ~typing.Callable[[~typing.Any], ~typing.Any] | None = None, shape: ~typing.List[~typing.Tuple] | ~typing.Tuple | int | None = None, permit_reshape: bool = True, cast_fn: ~typing.Callable[[~typing.Any], ~typing.Any] = <function ParameterBase.<lambda>>)
Instantiate a Rockpool registered attribute
- Parameters:
data (Optional[Any]) – Concrete initialisation data for this attribute. The shape of
data
will specify the allowable shape of the attribute data, unless theshape
argument is provided.family (Optional[str]) – An arbitrary string to specify the “family” of this attribute. You should use
'weights'
,'taus'
,'biases'
if you can; otherwise you can use whatever you like. These are used by theModule.parameters()
,Module.state()
andModule.simulation_parameters()
methods to group and select attributes.init_func (Optional[Callable]) – A function that initialises this attributed. Called by
Module.reset_parameters()
andModule.reset_state()
. The signature isf(shape: tuple) -> np.ndarray
.shape (Optional[Union[List[Tuple], Tuple, int]]) – A list of permisable shapes for the parameter, or a tuple specifying the permitted shape, or an integer specifying the number of elements. If not provided, the shape of the concrete initialisation data will be used as the attribute shape. The first item in the list will be used as the concrete shape, if
data
is not provided andinit_func
should be used.permit_reshape (bool) – If
True
, the input data will be reshaped to a matching permitted shape. IfFalse
, then an error will be raised if the shapes do not match exactly.cast_fn (Optional[Callable]) – A function to call to cast the data for this parameter. Will only be called once on initialisation.
- _tree_flatten() Tuple[tuple, tuple]
FLatten this parameter / state for Jax
- classmethod _tree_unflatten(_, children)
Unflatten a tree of parameter from Jax to Rockpool