class parameters.Parameter(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 parameter

A Parameter in Rockpool is a configuration value that is important for communicating the configuration of a network. For example, network weights; network time constants; neuron biases; etc. These are likely to be your set of trainable parameters for a module or network.

See also

See State for representing the transient internal state of a neuron or module, and SimulationParameter 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

  • data (Optional[Any]) – Concrete initialisation data for this attribute. The shape of data will specify the allowable shape of the attribute data, unless the shape 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 the Module.parameters(), Module.state() and Module.simulation_parameters() methods to group and select attributes.

  • init_func (Optional[Callable]) – A function that initialises this attributed. Called by Module.reset_parameters() and Module.reset_state(). The signature is f(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 and init_func should be used.

  • permit_reshape (bool) – If True, the input data will be reshaped to a matching permitted shape. If False, 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