ngclearn.components.neurons.spiking package

Submodules

ngclearn.components.neurons.spiking.LIFCell module

class ngclearn.components.neurons.spiking.LIFCell.LIFCell(*args: Any, **kwargs: Any)[source]

Bases: Component

A spiking cell based on leaky integrate-and-fire (LIF) neuronal dynamics.

Parameters:
  • name – the string name of this cell

  • n_units – number of cellular entities (neural population size)

  • tau_m – membrane time constant

  • R_m – membrane resistance value

  • thr – base value for adaptive thresholds that govern short-term plasticity (in milliVolts, or mV)

  • v_rest – membrane resting potential (in mV)

  • v_reset – membrane reset potential (in mV) – upon occurrence of a spike, a neuronal cell’s membrane potential will be set to this value

  • tau_theta – homeostatic threshold time constant

  • theta_plus – physical increment to be applied to any threshold value if a spike was emitted

  • refract_T – relative refractory period time (ms; Default: 1 ms)

  • one_spike – if True, a single-spike constraint will be enforced for every time step of neuronal dynamics simulated, i.e., at most, only a single spike will be permitted to emit per step – this means that if > 1 spikes emitted, a single action potential will be randomly sampled from the non-zero spikes detected

  • key – PRNG key to control determinism of any underlying random values associated with this cell

  • useVerboseDict – triggers slower, verbose dictionary mode (Default: False)

  • directory – string indicating directory on disk to save LIF parameter values to (i.e., initial threshold values and any persistent adaptive threshold values)

advance_state(t, dt, **kwargs)[source]
property current
classmethod inputCompartmentName()[source]
load(directory, **kwargs)[source]
classmethod outputCompartmentName()[source]
property refract
classmethod refractCompartmentName()[source]
reset(**kwargs)[source]
save(directory, **kwargs)[source]
property spikes
classmethod thresholdThetaName()[source]
property threshold_theta
property timeOfLastSpike
classmethod timeOfLastSpikeCompartmentName()[source]
verify_connections()[source]
property voltage
classmethod voltageCompartmentName()[source]
ngclearn.components.neurons.spiking.LIFCell.run_cell(dt, j, v, v_thr, v_theta, rfr, skey, tau_m, R_m, v_rest, v_reset, refract_T)

Runs leaky integrator neuronal dynamics

Parameters:
  • dt – integration time constant (milliseconds, or ms)

  • j – electrical current value

  • v – membrane potential (voltage, in milliVolts or mV) value (at t)

  • v_thr – base voltage threshold value (in mV)

  • v_theta – threshold shift (homeostatic) variable (at t)

  • rfr – refractory variable vector (one per neuronal cell)

  • skey – PRNG key which, if not None, will trigger a single-spike constraint (i.e., only one spike permitted to emit per single step of time); specifically used to randomly sample one of the possible action potentials to be an emitted spike

  • tau_m – cell membrane time constant

  • R_m – membrane resistance value

  • v_rest – membrane resting potential (in mV)

  • v_reset – membrane reset potential (in mV) – upon occurrence of a spike, a neuronal cell’s membrane potential will be set to this value

  • refract_T – (relative) refractory time period (in ms; Default value is 1 ms)

Returns:

voltage(t+dt), spikes, raw spikes, updated refactory variables

ngclearn.components.neurons.spiking.LIFCell.update_theta(dt, v_theta, s, tau_theta, theta_plus=0.05)

Runs homeostatic threshold update dynamics one step.

Parameters:
  • dt – integration time constant (milliseconds, or ms)

  • v_theta – current value of homeostatic threshold variable

  • s – current spikes (at t)

  • tau_theta – homeostatic threshold time constant

  • theta_plus – physical increment to be applied to any threshold value if a spike was emitted

Returns:

updated homeostatic threshold variable

ngclearn.components.neurons.spiking.LIFCell.update_times(t, s, tols)

Updates time-of-last-spike (tols) variable.

Parameters:
  • t – current time (a scalar/int value)

  • s – binary spike vector

  • tols – current time-of-last-spike variable

Returns:

updated tols variable

ngclearn.components.neurons.spiking.fitzhughNagumoCell module

class ngclearn.components.neurons.spiking.fitzhughNagumoCell.FitzhughNagumoCell(*args: Any, **kwargs: Any)[source]

Bases: Component

The Fitzhugh-Nagumo neuronal cell model; a two-variable simplification of the Hodgkin-Huxley (squid axon) model. This cell model iteratively evolves voltage “v” and recovery “w” (which represents the combined effects of sodium channel deinactivation and potassium channel deactivation in the Hodgkin-Huxley model).

The specific pair of differential equations that characterize this cell are (for adjusting v and w, given current j, over time):

tau_m * dv/dt = v - (v^3)/3 - w + j
tau_w * dw/dt = v + a - b * w
References:
FitzHugh, Richard. “Impulses and physiological states in theoretical
models of nerve membrane.” Biophysical journal 1.6 (1961): 445-466.

Nagumo, Jinichi, Suguru Arimoto, and Shuji Yoshizawa. “An active pulse
transmission line simulating nerve axon.” Proceedings of the IRE 50.10
(1962): 2061-2070.
Parameters:
  • name – the string name of this cell

  • n_units – number of cellular entities (neural population size)

  • tau_m – membrane time constant

  • tau_w – recover variable time constant (Default: 12.5 ms)

  • alpha – dimensionless recovery variable shift factor “a” (Default: 0.7)

  • beta – dimensionless recovery variable scale factor “b” (Default: 0.8)

  • gamma – power-term divisor (Default: 3.)

  • v_thr – voltage/membrane threshold (to obtain action potentials in terms of binary spikes)

  • v0 – initial condition / reset for voltage

  • w0 – initial condition / reset for recovery

  • integration_type

    type of integration to use for this cell’s dynamics; current supported forms include “euler” (Euler/RK-1 integration) and “midpoint” or “rk2” (midpoint method/RK-2 integration) (Default: “euler”)

    Note:

    setting the integration type to the midpoint method will increase the accuray of the estimate of the cell’s evolution at an increase in computational cost (and simulation time)

  • key – PRNG key to control determinism of any underlying synapses associated with this cell

  • useVerboseDict – triggers slower, verbose dictionary mode (Default: False)

advance_state(t, dt, **kwargs)[source]
property inputCompartment
classmethod inputCompartmentName()[source]
property outputCompartment
classmethod outputCompartmentName()[source]
property recovery
classmethod recoveryName()[source]
reset(**kwargs)[source]
save(**kwargs)[source]
property timeOfLastSpike
classmethod timeOfLastSpikeCompartmentName()[source]
verify_connections()[source]
property voltage
classmethod voltageName()[source]
ngclearn.components.neurons.spiking.fitzhughNagumoCell.run_cell(dt, j, v, w, v_thr, tau_m, tau_w, a, b, g=3.0, integType=0)[source]
Parameters:
  • dt – integration time constant

  • j – electrical current

  • v – membrane potential / voltage

  • w – recovery variable value(s)

  • v_thr – voltage/membrane threshold (to obtain action potentials in terms of binary spikes)

  • tau_m – membrane time constant

  • tau_w – recover variable time constant (Default: 12.5 ms)

  • a – dimensionless recovery variable shift factor “alpha” (Default: 0.7)

  • b – dimensionless recovery variable scale factor “beta” (Default: 0.8)

  • g – power-term divisor ‘gamma’ (Default: 3.)

  • integType – integration type to use (0 –> Euler/RK1, 1 –> Midpoint/RK2)

Returns:

updated voltage, updated recovery, spikes

ngclearn.components.neurons.spiking.fitzhughNagumoCell.update_times(t, s, tols)

Updates time-of-last-spike (tols) variable.

Parameters:
  • t – current time (a scalar/int value)

  • s – binary spike vector

  • tols – current time-of-last-spike variable

Returns:

updated tols variable

ngclearn.components.neurons.spiking.izhikevichCell module

class ngclearn.components.neurons.spiking.izhikevichCell.IzhikevichCell(*args: Any, **kwargs: Any)[source]

Bases: Component

A spiking cell based on Izhikevich’s model of neuronal dynamics. Note that this a two-variable simplification of more complex multi-variable systems (e.g., Hodgkin-Huxley model). This cell model iteratively evolves voltage “v” and recovery “w”, the last of which represents the combined effects of sodium channel deinactivation and potassium channel deactivation.

The specific pair of differential equations that characterize this cell are (for adjusting v and w, given current j, over time):

tau_m * dv/dt = 0.04 v^2 + 5v + 140 - w + j * R_m
tau_w * dw/dt = (v * b - w), where tau_w = 1/a
References:
Izhikevich, Eugene M. “Simple model of spiking neurons.” IEEE Transactions
on neural networks 14.6 (2003): 1569-1572.

Note: Izhikevich’s constants/hyper-parameters ‘a’, ‘b’, ‘c’, and ‘d’ have been remapped/renamed (see arguments below). Note that the default settings for this component cell is for a regular spiking cell; to recover other types of spiking cells (depending on what neuronal circuitry one wants to model), one can recover specific models with the following particular values:

Intrinsically bursting neurons: v_reset=-55, w_reset=4
Chattering neurons: v_reset = -50, w_reset = 2
Fast spiking neurons: tau_w = 10
Low-threshold spiking neurons: tau_w = 10, coupling_factor = 0.25, w_reset = 2
Resonator neurons: tau_w = 10, coupling_factor = 0.26
Parameters:
  • name – the string name of this cell

  • n_units – number of cellular entities (neural population size)

  • tau_m – membrane time constant (Default: 1 ms)

  • R_m – membrane resistance value

  • v_thr – voltage threshold value to cross for emitting a spike (in milliVolts, or mV) (Default: 30 mV)

  • v_reset – voltage value to reset to after a spike (in mV) (Default: -65 mV), i.e., ‘c’

  • tau_w – recovery variable time constant (Default: 50 ms), i.e., 1/’a’

  • w_reset – recovery value to reset to after a spike (Default: 8), i.e., ‘d’

  • coupling_factor – degree of to which recovery is sensitive to any subthreshold fluctuations of voltage (Default: 0.2), i.e., ‘b’

  • v0 – initial condition / reset for voltage (Default: -65 mV)

  • w0 – initial condition / reset for recovery (Default: -14)

  • key – PRNG key to control determinism of any underlying random values associated with this cell

  • integration_type

    type of integration to use for this cell’s dynamics; current supported forms include “euler” (Euler/RK-1 integration) and “midpoint” or “rk2” (midpoint method/RK-2 integration) (Default: “euler”)

    Note:

    setting the integration type to the midpoint method will increase the accuray of the estimate of the cell’s evolution at an increase in computational cost (and simulation time)

  • useVerboseDict – triggers slower, verbose dictionary mode (Default: False)

advance_state(t, dt, **kwargs)[source]
property inputCompartment
classmethod inputCompartmentName()[source]
property outputCompartment
classmethod outputCompartmentName()[source]
property recovery
classmethod recoveryName()[source]
reset(**kwargs)[source]
save(directory, **kwargs)[source]
property timeOfLastSpike
classmethod timeOfLastSpikeCompartmentName()[source]
verify_connections()[source]
property voltage
classmethod voltageName()[source]
ngclearn.components.neurons.spiking.izhikevichCell.run_cell(dt, j, v, s, w, v_thr=30.0, tau_m=1.0, tau_w=50.0, b=0.2, c=-65.0, d=8.0, R_m=1.0, integType=0)[source]

Runs Izhikevich neuronal dynamics

Parameters:
  • dt – integration time constant (milliseconds, or ms)

  • j – electrical current value

  • v – membrane potential (voltage, in milliVolts or mV) value (at t)

  • s – previously measured spikes/action potentials (binary values)

  • w – recovery variable/state

  • v_thr – voltage threshold value (in mV)

  • tau_m – membrane time constant

  • tau_w – (tau_recovery) time scale/constant of recovery variable; note that this is the inverse of Izhikevich’s scale variable a (tau_w = 1/a)

  • b – (coupling factor) how sensitive is recovery to subthreshold voltage fluctuations

  • c – (reset_voltage) voltage to reset to after spike emitted (in mV)

  • d – (reset_recovery) recovery value to reset to after a spike

  • R_m – membrane resistance value (Default: 1 mega-Ohm)

  • integType – integration type to use (0 –> Euler/RK1, 1 –> Midpoint/RK2)

Returns:

updated voltage, updated recovery, spikes

ngclearn.components.neurons.spiking.izhikevichCell.update_times(t, s, tols)

Updates time-of-last-spike (tols) variable.

Parameters:
  • t – current time (a scalar/int value)

  • s – binary spike vector

  • tols – current time-of-last-spike variable

Returns:

updated tols variable

ngclearn.components.neurons.spiking.quadLIFCell module

class ngclearn.components.neurons.spiking.quadLIFCell.QuadLIFCell(*args: Any, **kwargs: Any)[source]

Bases: Component

A spiking cell based on quadratic leaky integrate-and-fire (LIF) neuronal dynamics.

Dynamics can be taken to be governed by the following ODE:

d.Vz/d.t = a0 * (V - V_rest) * (V - V_c) + Jz * R) * (dt/tau_mem)

where:

a0 - scaling factor for voltage accumulation
V_c - critical voltage (value)
Parameters:
  • name – the string name of this cell

  • n_units – number of cellular entities (neural population size)

  • tau_m – membrane time constant

  • R_m – membrane resistance value

  • thr – base value for adaptive thresholds that govern short-term plasticity (in milliVolts, or mV)

  • v_rest – membrane resting potential (in mV)

  • v_reset – membrane reset potential (in mV) – upon occurrence of a spike, a neuronal cell’s membrane potential will be set to this value

  • v_scale – scaling factor for voltage accumulation (v_c)

  • critical_V – critical voltage value (a0)

  • tau_theta – homeostatic threshold time constant

  • theta_plus – physical increment to be applied to any threshold value if a spike was emitted

  • refract_T – relative refractory period time (ms; Default: 1 ms)

  • one_spike – if True, a single-spike constraint will be enforced for every time step of neuronal dynamics simulated, i.e., at most, only a single spike will be permitted to emit per step – this means that if > 1 spikes emitted, a single action potential will be randomly sampled from the non-zero spikes detected

  • key – PRNG key to control determinism of any underlying random values associated with this cell

  • useVerboseDict – triggers slower, verbose dictionary mode (Default: False)

  • directory – string indicating directory on disk to save LIF parameter values to (i.e., initial threshold values and any persistent adaptive threshold values)

advance_state(t, dt, **kwargs)[source]
property current
classmethod inputCompartmentName()[source]
load(directory, **kwargs)[source]
classmethod outputCompartmentName()[source]
property refract
classmethod refractCompartmentName()[source]
reset(**kwargs)[source]
save(directory, **kwargs)[source]
property spikes
classmethod thresholdThetaName()[source]
property threshold_theta
property timeOfLastSpike
classmethod timeOfLastSpikeCompartmentName()[source]
verify_connections()[source]
property voltage
classmethod voltageCompartmentName()[source]
ngclearn.components.neurons.spiking.quadLIFCell.run_cell(dt, j, v, v_thr, v_theta, rfr, skey, v_c, a0, tau_m, R_m, v_rest, v_reset, refract_T)

Runs quadratic leaky integrator neuronal dynamics

Parameters:
  • dt – integration time constant (milliseconds, or ms)

  • j – electrical current value

  • v – membrane potential (voltage, in milliVolts or mV) value (at t)

  • v_thr – base voltage threshold value (in mV)

  • v_theta – threshold shift (homeostatic) variable (at t)

  • rfr – refractory variable vector (one per neuronal cell)

  • skey – PRNG key which, if not None, will trigger a single-spike constraint (i.e., only one spike permitted to emit per single step of time); specifically used to randomly sample one of the possible action potentials to be an emitted spike

  • v_c – scaling factor for voltage accumulation

  • a0 – critical voltage value

  • tau_m – cell membrane time constant

  • R_m – membrane resistance value

  • v_rest – membrane resting potential (in mV)

  • v_reset – membrane reset potential (in mV) – upon occurrence of a spike, a neuronal cell’s membrane potential will be set to this value

  • refract_T – (relative) refractory time period (in ms; Default value is 1 ms)

Returns:

voltage(t+dt), spikes, raw spikes, updated refactory variables

ngclearn.components.neurons.spiking.quadLIFCell.update_theta(dt, v_theta, s, tau_theta, theta_plus=0.05)

Runs homeostatic threshold update dynamics one step.

Parameters:
  • dt – integration time constant (milliseconds, or ms)

  • v_theta – current value of homeostatic threshold variable

  • s – current spikes (at t)

  • tau_theta – homeostatic threshold time constant

  • theta_plus – physical increment to be applied to any threshold value if a spike was emitted

Returns:

updated homeostatic threshold variable

ngclearn.components.neurons.spiking.quadLIFCell.update_times(t, s, tols)

Updates time-of-last-spike (tols) variable.

Parameters:
  • t – current time (a scalar/int value)

  • s – binary spike vector

  • tols – current time-of-last-spike variable

Returns:

updated tols variable

ngclearn.components.neurons.spiking.sLIFCell module

class ngclearn.components.neurons.spiking.sLIFCell.SLIFCell(*args: Any, **kwargs: Any)[source]

Bases: Component

A spiking cell based on a simplified leaky integrate-and-fire (sLIF) model. This neuronal cell notably contains functionality required by the computational model employed by (Samadi et al., 2017, i.e., a surrogate derivative function and “sticky spikes”) as well as the additional incorporation of an adaptive threshold (per unit) scheme. (Note that this particular spiking cell only supports Euler integration of its voltage dynamics.)

Reference:
Samadi, Arash, Timothy P. Lillicrap, and Douglas B. Tweed. “Deep learning with
dynamic spiking neurons and fixed feedback weights.” Neural computation 29.3
(2017): 578-602.
Parameters:
  • name – the string name of this cell

  • n_units – number of cellular entities (neural population size)

  • tau_m – membrane time constant

  • R_m – membrane resistance value

  • thr – base value for adaptive thresholds (initial condition for per-cell thresholds) that govern short-term plasticity

  • inhibit_R – lateral modulation factor (DEFAULT: 6.); if >0, this will trigger a heuristic form of lateral inhibition via an internally integrated hollow matrix multiplication

  • thr_persist

    are adaptive thresholds persistent? (Default: False)

    Note:

    depending on the value of this boolean variable: True = adaptive thresholds are NEVER reset upon call to reset False = adaptive thresholds are reset to “thr” upon call to reset

  • thrGain – how much adaptive thresholds increment by

  • thrLeak – how much adaptive thresholds are decremented/decayed by

  • refract_T – relative refractory period time (ms; Default: 1 ms)

  • rho_b – threshold sparsity factor (Default: 0)

  • sticky_spikes – if True, spike variables will be pinned to action potential value (i.e, 1) throughout duration of the refractory period; this recovers a key setting used by Samadi et al., 2017

  • thr_jitter – scale of uniform jitter to add to initialization of thresholds

  • key – PRNG key to control determinism of any underlying random values associated with this cell

  • useVerboseDict – triggers slower, verbose dictionary mode (Default: False)

  • directory – string indicating directory on disk to save sLIF parameter values to (i.e., initial threshold values and any persistent adaptive threshold values)

advance_state(t, dt, **kwargs)[source]
property current
classmethod inputCompartmentName()[source]
load(directory, **kwargs)[source]
classmethod outputCompartmentName()[source]
property refract
classmethod refractCompartmentName()[source]
reset(**kwargs)[source]
save(directory, **kwargs)[source]
property spikes
property surrogate
classmethod surrogateCompartmentName()[source]
property threshold
classmethod thresholdCompartmentName()[source]
property timeOfLastSpike
classmethod timeOfLastSpikeCompartmentName()[source]
verify_connections()[source]
property voltage
classmethod voltageCompartmentName()[source]
ngclearn.components.neurons.spiking.sLIFCell.modify_current(j, spikes, inh_weights, R_m, inh_R)

A simple function that modifies electrical current j via application of a scalar membrane resistance value and an approximate form of lateral inhibition. Note that if no inhibitory resistance is set (i.e., inh_R = 0), then no lateral inhibition is applied. Functionally, this routine carries out the following piecewise equation:

j * R_m - [Wi * s(t-dt)] * inh_R, if inh_R > 0
j * R_m, otherwise
Parameters:
  • j – electrical current value

  • spikes – previous binary spike vector (for t-dt)

  • inh_weights – lateral recurrent inhibitory synapses (typically should be chosen to be a scaled hollow matrix)

  • R_m – membrane resistance (to multiply/scale j by)

  • inh_R – inhibitory resistance to scale lateral inhibitory current by; if inh_R = 0, NO lateral inhibitory pressure will be applied

Returns:

modified electrical current value

ngclearn.components.neurons.spiking.sLIFCell.run_cell(dt, j, v, v_thr, tau_m, rfr, spike_fx, refract_T=1.0, thrGain=0.002, thrLeak=0.0005, rho_b=0.0, sticky_spikes=False, v_min=None)[source]

Runs leaky integrator neuronal dynamics

Parameters:
  • dt – integration time constant (milliseconds, or ms)

  • j – electrical current value

  • v – membrane potential (voltage) value (at t)

  • v_thr – voltage threshold value (at t)

  • tau_m – cell membrane time constant

  • rfr – refractory variable vector (one per neuronal cell)

  • spike_fx – spike emission function of form spike_fx(v, v_thr)

  • refract_T – (relative) refractory time period (in ms; Default value is 1 ms)

  • thrGain – the amount of threshold incremented per time step (if spike present)

  • thrLeak – the amount of threshold value leaked per time step

  • rho_b – sparsity factor; if > 0, will force adaptive threshold to operate with sparsity across a layer enforced

  • sticky_spikes – if True, then spikes are pinned at value of action potential (i.e., 1) for as long as the relative refractory occurs (this recovers the source paper’s core spiking process)

Returns:

voltage(t+dt), spikes, threshold(t+dt), updated refactory variables

ngclearn.components.neurons.spiking.sLIFCell.update_times(t, s, tols)

Updates time-of-last-spike (tols) variable.

Parameters:
  • t – current time (a scalar/int value)

  • s – binary spike vector

  • tols – current time-of-last-spike variable

Returns:

updated tols variable

Module contents