Dynamics#

class braincore.Dynamics(size, keep_size=False, name=None, mode=None, method='exp_auto')#

Dynamical System class.

Note

In general, every instance of Module implemented in BrainPy only defines the evolving function at each time step \(t\).

If users want to define the logic of running models across multiple steps, we recommend users to use for_loop(), LoopOverTime, DSRunner, or DSTrainer.

To be compatible with previous APIs, Module inherits from the DelayRegister. It’s worthy to note that the methods of DelayRegister will be removed in the future, including:

  • .register_delay()

  • .get_delay_data()

  • .update_local_delays()

  • .reset_local_delays()

There are several essential attributes:

  • size: the geometry of the neuron group. For example, (10, ) denotes a line of neurons, (10, 10) denotes a neuron group aligned in a 2D space, (10, 15, 4) denotes a 3-dimensional neuron group.

  • num: the flattened number of neurons in the group. For example, size=(10, ) => num=10, size=(10, 10) => num=100, size=(10, 15, 4) => num=600.

Parameters:
get_return_delay_at(delay_name)[source]#

Get the state delay at the given identifier (name).

See also register_state_delay().

Parameters:

delay_name – The identifier of the delay.

Returns:

The delayed data at the given delay position.

register_return_delay(delay_name, delay_time=None, delay_step=None)[source]#

Register local relay at the given delay time.

Parameters:
  • delay_name (str) – str. The name of the current delay data.

  • delay_time (Union[Array, ndarray, bool_, number, bool, int, float, complex, None]) – The delay time. Float.

  • delay_step (Union[Array, ndarray, bool_, number, bool, int, float, complex, None]) – The delay step. Int. delay_step and delay_time are exclusive. delay_step = delay_time / dt.

update_return()[source]#

The update function return of the model.

It should be a pytree, with each element as a jax.ShapeDtypeStruct or jax.core.ShapedArray.

Return type:

Any

update_return_info()[source]#

The update return information of the model.

It should be a pytree, with each element as a jax.Array. :rtype: Any

Note

Should not include the batch axis and batch size. These information will be inferred from the mode attribute.

property varshape#

The shape of variables in the neuron group.