Dynamics

Different dynamical rules can be imposed on the nework. Each dynamic is organized into a separate file, implemented as a class (inherited from the base Dynamic) alongside all necessary integration methods and untilities.

Warning

These utilities and methods are aimed to be used only locally within the method of the corresponding class. They are exposed to user only for inspiration and guidance on how to extend for other rules.

Abstract Dynamics

class hetero.dynamics.base.Dynamic(sim_path, namespace, name, ext)[source]

Bases: object

Base class for for the dynamic object, that serves as containter for orchestrating the integration of the dynamical systems and storing them on the disk.

Parameters:
  • sim_path (str) – Path of the simulation directory

  • namespace (dict) – The dynaimc rule’s argument (passed to the integrators)

  • name (str) – Name of the specific dynamic rule

  • ext (str) – The extension of the state file (pkl or npy)

prepare_nets()[source]
scan_for_undone(state_name)[source]

Checks which networks are not yet integrated, and returns lists for the network ids and their corresponding time constants. These lists will be empty if all networks are integrated.

Rate Dynamics

Leaky-Integrator dynamic

The evolution of the membrane voltage \(v_i(t)\) of neuron \(i\) is described by the following rule:

\[\tau_i \frac{\mathrm{d}v_i}{\mathrm{d}t} = -v_i(t) + J \sum_j w_{ij} f(v_j(t)) + J_u \sum_k w_{ik} u_k(t) + J_n \xi(t)\]

where \(f(.)\) is some activation function and \('xi\) is the white noise imposed on the neuron. Note that time constants are in general neuron-specific, which renders the network heterogeneous.

class hetero.dynamics.li.LI(sim_path, namespace, dyn_params={})[source]

Bases: Dynamic

The object for integrating neworks of Leaking-Integrator (LI) neurons.

run(solver, state_name, stype=<class 'float'>, ncpu=-1, **kwargs)[source]

Runs the LI dynamic.

Parameters:
  • solver (str) – Integrator’s name (euler or runge_kutta)

  • state_name (str) – State file name

  • stype (str or type, optional) – The data type in which the state is stoerd on the disk, by default float

  • ncpu (int, optional) – Number of CPU cores to use. The default of -1 means use all.

hetero.dynamics.li.LI_grad(t, y, taus=None, A_adj=None, wu=None, w=None, Ju=1, J=1, Jn=1, af='possig', ut=None, xit=None, dt=1.0, delay=0, **kwargs)[source]

Implentation of the LI dynamics with noise.

hetero.dynamics.li.integrate_n_save_joblib(integrator, namespace, taus, net_ids, sim_path, state_name, stype, ncpu)[source]
hetero.dynamics.li.integrate_n_save_serial(integrator, namespace, taus, net_ids, sim_path, state_name, stype, ncpu)[source]
hetero.dynamics.li.forward_euler(**arg_dict)[source]

Implementation of the forward Euler solver.

hetero.dynamics.li.runge_kutta(**arg_dict)[source]

Implementation of the Runge-Kutta solver. This function is a wrapper around Scipy’s solve_ivp method.

hetero.dynamics.li.activation_func(x, af, x0=1.0, thr=0, **kwargs)[source]

Apply a specified activation function to input data with optional scaling and thresholding. The valid activation fucntions are:

  • ‘lin’: linear

  • ‘relu’: rectified linear unit

  • ‘caplin’ : same as ‘lin’ but capped between 0 and 1

  • ‘caprelu’: same as ‘relu’ but capped between 0 and 1

  • ‘capquad’: quadratic function capped between 0 and 1

  • ‘capcube’: cubic function capped between 0 and 1

  • ‘capcube’: cubic function capped between 0 and 1

  • ‘capexp’: exponential function capped between 0 and 1

  • ‘tanh’: tangent hyperbolic

  • symsig: an even sigmoidal function centered at t=0 with range between -1 and 1.

  • ‘possig’: sigmoidal function centered at y=0.5 with range between 0 and 1 .

  • ‘possig_plus’: same as ‘possig’ but only for values larger than threshold and zero otherwise.

  • ‘bell’ : non-normalized Gaussian activation function

  • ‘camel’: a gaussian multiplied by a pure quadratic function, resulting in two identical bumps

    at (±1, 1).

  • ‘switch’: a binary activation. Zero for values smaller than thr and 1 otherwise.

Parameters:
  • x (float or ndarray) – Input array or value to be transformed

  • af (str) – Name of the activation function to apply (e.g., ‘relu’, ‘tanh’, ‘possig’, etc.)

  • x0 (float) – Scaling factor for the input (default: 1.0)

  • thr (float) – Threshold (bias) value to shift the input (default: 0)

  • kwargs (dict) – Additional keyword arguments for specific activation functions

Returns:

The result of applying the chosen activation function to the input

Return type:

float or ndarray

Spiking Dynamics