parameters.ParameterBase

class parameters.ParameterBase(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: object

Base class for Rockpool registered attributes

See also

See Parameter for representing the configuration of a module, 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>>)[source]

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 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][source]

FLatten this parameter / state for Jax

classmethod _tree_unflatten(_, children)[source]

Unflatten a tree of parameter from Jax to Rockpool