ngclearn.components.neurons.spiking package
Submodules
ngclearn.components.neurons.spiking.IFCell module
- class ngclearn.components.neurons.spiking.IFCell.IFCell(*args, **kwargs)[source]
Bases:
JaxComponentA spiking cell based on integrate-and-fire (IF) neuronal dynamics.
The specific differential equation that characterizes this cell is (for adjusting v, given current j, over time) is:
tau_m * dv/dt = j * Rwhere R is the membrane resistance and v_rest is the resting potentialalso, if a spike occurs, v is set to v_reset— Cell Input Compartments: —j - electrical current input (takes in external signals)— Cell State Compartments: —v - membrane potential/voltage staterfr - (relative) refractory variable statekey - JAX PRNG key— Cell Output Compartments: —s - emitted binary spikes/action potentialss_raw - raw spike signals before post-processing (only if one_spike = True, else s_raw = s)tols - time-of-last-spike- Parameters:
name – the string name of this cell
n_units – number of cellular entities (neural population size)
tau_m – membrane time constant
resist_m – membrane resistance value (default: 1)
thr – base value for adaptive thresholds that govern short-term plasticity (in milliVolts, or mV; default: -52. mV)
v_rest – membrane resting potential (in mV; default: -65 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; (default: -60 mV)
refract_time – relative refractory period time (ms; default: 0 ms)
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 accuracy of the estimate of the cell’s evolution at an increase in computational cost (and simulation time)
surrogate_type –
type of surrogate function to use for approximating a partial derivative of this cell’s spikes w.r.t. its voltage/current (default: “straight_through”)
- Note:
surrogate options available include: “straight_through” (straight-through estimator), “triangular” (triangular estimator), and “arctan” (arc-tangent estimator)
lower_clamp_voltage – if True, this will ensure voltage never is below the value of v_rest (default: True)
ngclearn.components.neurons.spiking.LIFCell module
- class ngclearn.components.neurons.spiking.LIFCell.LIFCell(*args, **kwargs)[source]
Bases:
JaxComponentA spiking cell based on leaky integrate-and-fire (LIF) neuronal dynamics.
The specific differential equation that characterizes this cell is (for adjusting v, given current j, over time) is:
tau_m * dv/dt = (v_rest - v) + j * Rwhere R is the membrane resistance and v_rest is the resting potentialalso, if a spike occurs, v is set to v_reset— Cell Input Compartments: —j - electrical current input (takes in external signals)— Cell State Compartments: —v - membrane potential/voltage staterfr - (relative) refractory variable statethr_theta - homeostatic/adaptive threshold increment statekey - JAX PRNG key— Cell Output Compartments: —s - emitted binary spikes/action potentialss_raw - raw spike signals before post-processing (only if one_spike = True, else s_raw = s)tols - time-of-last-spike- Parameters:
name – the string name of this cell
n_units – number of cellular entities (neural population size)
tau_m – membrane time constant
resist_m – membrane resistance value (Default: 1)
thr – base value for adaptive thresholds that govern short-term plasticity (in milliVolts, or mV; default: -52. mV)
v_rest – reversal potential or membrane resting potential (in mV; default: -65 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; (default: -60 mV)
conduct_leak – leak conductance (g_L) value or decay factor applied to voltage leak (Default: 1.); setting this to 0 mV recovers pure integrate-and-fire (IF) dynamics
tau_theta – homeostatic threshold time constant
theta_plus – physical increment to be applied to any threshold value if a spike was emitted
refract_time – relative refractory period time (ms; Default: 5 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 (Default: False)
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 accuracy of the estimate of the cell’s evolution at an increase in computational cost (and simulation time)
surrogate_type –
type of surrogate function to use for approximating a partial derivative of this cell’s spikes w.r.t. its voltage/current (default: “straight_through”)
- Note:
surrogate options available include: “straight_through” (straight-through estimator), “triangular” (triangular estimator), “arctan” (arc-tangent estimator), and “secant_lif” (the LIF-specialized secant estimator)
v_min – minimum voltage to clamp dynamics to (Default: None)
ngclearn.components.neurons.spiking.RAFCell module
- class ngclearn.components.neurons.spiking.RAFCell.RAFCell(*args, **kwargs)[source]
Bases:
JaxComponentThe resonate-and-fire (RAF) neuronal cell model; a two-variable model. This cell model iteratively evolves voltage “v” and angular driver “w”.
The specific pair of differential equations that characterize this cell are (for adjusting v and w, given current j, over time):
tau_w * dw/dt = w * b - v * omega + jtau_v * dv/dt = omega * w + v * bwhere omega is angular frequency (Hz) and b is exponential dampening factorNote: injected current j should generally be scaled by tau_w/dt— Cell Input Compartments: —j - electrical current input (takes in external signals)— Cell State Compartments: —v - membrane potential/voltage statew - angular driver variable statekey - JAX PRNG key— Cell Output Compartments: —s - emitted binary spikes/action potentialstols - time-of-last-spikeReferences:Izhikevich, Eugene M. “Resonate-and-fire neurons.” Neural networks 14.6-7 (2001): 883-894.- Parameters:
name – the string name of this cell
n_units – number of cellular entities (neural population size)
tau_v – membrane/voltage time constant (Default: 1 ms)
tau_w – angular driver variable time constant (Default: 1 ms)
thr – voltage/membrane threshold (to obtain action potentials in terms of binary spikes) (Default: 1 mV)
omega – angular frequency (Default: 10)
dampen_factor – oscillation dampening factor (Default: -1) (“b” in Izhikevich 2001)
v_reset – reset condition for membrane potential (Default: 1 mV)
w_reset – reset condition for angular current driver (Default: 0)
v0 – initial condition for membrane potential (Default: 1 mV)
w0 – initial condition for angular current driver (Default: 0)
resist_v – membrane resistance (Default: 1 mega-Ohm)
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 accuracy of the estimate of the cell’s evolution at an increase in computational cost (and simulation time)
ngclearn.components.neurons.spiking.WTASCell module
- class ngclearn.components.neurons.spiking.WTASCell.WTASCell(*args, **kwargs)[source]
Bases:
JaxComponentA spiking cell based on winner-take-all neuronal dynamics (“WTAS” stands for “winner-take-all-spiking”).
The differential equation for adjusting this specific cell (for adjusting v, given current j, over time) is:
tau_m * dv/dt = j * R ; v_p = softmax(v)where R is membrane resistance and v_p is a voltage probability vector— Cell Input Compartments: —j - electrical current input (takes in external signals)— Cell State Compartments: —v - membrane potential/voltage staterfr - (relative) refractory variable statethr - (adaptive) threshold statekey - JAX PRNG key— Cell Output Compartments: —s - emitted binary spikes/action potentialstols - time-of-last-spike- Parameters:
name – the string name of this cell
n_units – number of cellular entities (neural population size)
tau_m – membrane time constant
resist_m – membrane resistance value (Default: 1)
thr_base – base value for adaptive thresholds that govern short-term plasticity (in milliVolts, or mV)
thr_gain – increment to be applied to threshold in presence of spike
refract_time – relative refractory period time (ms; Default: 1 ms)
thr_jitter – scale of uniform jitter to add to initialization of thresholds
ngclearn.components.neurons.spiking.adExCell module
- class ngclearn.components.neurons.spiking.adExCell.AdExCell(*args, **kwargs)[source]
Bases:
JaxComponentThe AdEx (adaptive exponential leaky integrate-and-fire) neuronal cell model; a two-variable model. This cell model iteratively evolves voltage “v” and recovery “w”.
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_rest) + sharpV * exp((v - vT)/sharpV) - R_m * w + R_m * jtau_w * dw/dt = -w + (v - v_rest) * awhere w = w + s * (w + b) [in the event of a spike]— Cell Input Compartments: —j - electrical current input (takes in external signals)— Cell State Compartments: —v - membrane potential/voltage statew - recovery variable statekey - JAX PRNG key— Cell Output Compartments: —s - emitted binary spikes/action potentialstols - time-of-last-spikeReferences:Brette, Romain, and Wulfram Gerstner. “Adaptive exponential integrate-and-firemodel as an effective description of neuronal activity.” Journal ofneurophysiology 94.5 (2005): 3637-3642.- Parameters:
name – the string name of this cell
n_units – number of cellular entities (neural population size)
tau_m – membrane time constant (Default: 15 ms)
resist_m – membrane resistance (Default: 1 mega-Ohm)
tau_w – recover variable time constant (Default: 400 ms)
v_sharpness – slope factor/sharpness constant (Default: 2)
intrinsic_mem_thr – intrinsic membrane threshold (Default: -55 mV)
thr – voltage/membrane threshold (to obtain action potentials in terms of binary spikes) (Default: 5 mV)
v_rest – membrane resting potential (Default: -72 mV)
a – adaptation coupling parameter (Default: 0.1)
b – adaption/recover increment value (Default: 0.75)
v0 – initial condition / reset for voltage (Default: -70 mV)
w0 – initial condition / reset for recovery (Default: 0 mV)
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 accuracy of the estimate of the cell’s evolution at an increase in computational cost (and simulation time)
ngclearn.components.neurons.spiking.fitzhughNagumoCell module
- class ngclearn.components.neurons.spiking.fitzhughNagumoCell.FitzhughNagumoCell(*args, **kwargs)[source]
Bases:
JaxComponentThe 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 + jtau_w * dw/dt = v + a - b * w— Cell Input Compartments: —j - electrical current input (takes in external signals)— Cell State Compartments: —v - membrane potential/voltage statew - recovery variable statekey - JAX PRNG key— Cell Output Compartments: —s - emitted binary spikes/action potentialstols - time-of-last-spikeReferences:FitzHugh, Richard. “Impulses and physiological states in theoreticalmodels of nerve membrane.” Biophysical journal 1.6 (1961): 445-466.Nagumo, Jinichi, Suguru Arimoto, and Shuji Yoshizawa. “An active pulsetransmission 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
resist_m – membrane resistance value
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.)
v0 – initial condition / reset for voltage
w0 – initial condition / reset for recovery
v_thr – voltage/membrane threshold (to obtain action potentials in terms of binary spikes)
spike_reset – if True, once voltage crosses threshold, then dynamics of voltage and recovery are reset/snapped to initial conditions (default: False)
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 accuracy of the estimate of the cell’s evolution at an increase in computational cost (and simulation time)
ngclearn.components.neurons.spiking.hodgkinHuxleyCell module
- class ngclearn.components.neurons.spiking.hodgkinHuxleyCell.HodgkinHuxleyCell(*args, **kwargs)[source]
Bases:
JaxComponentA spiking cell based the Hodgkin-Huxley (H-H) 1952 set of dynamics for describing the ionic mechanisms that underwrite the initiation and propagation of action potentials within a (giant) squid axon.
The four differential equations for adjusting this specific cell (for adjusting v, given current j, over time) are:
tau_v dv/dt = j - g_Na * m^3 * h * (v - v_Na) - g_K * n^4 * (v - v_K) - g_L * (v - v_L)dn/dt = alpha_n(v) * (1 - n) - beta_n(v) * ndm/dt = alpha_m(v) * (1 - m) - beta_m(v) * mdh/dt = alpha_h(v) * (1 - h) - beta_h(v) * hwhere alpha_x(v) and beta_x(v) are functions that produce relevant biophysical constant valuesdepending on which gate/channel is being probed (i.e., x = n or m or h)— Cell Input Compartments: —j - electrical current input (takes in external signals)— Cell State Compartments: —v - membrane potential/voltage staten - dimensionless probabilities for potassium channel subunit activationm - dimensionless probabilities for sodium channel subunit activationh - dimensionless probabilities for sodium channel subunit inactivationkey - JAX PRNG key— Cell Output Compartments: —s - emitted binary spikes/action potentialstols - time-of-last-spikeReferences:Hodgkin, Alan L., and Andrew F. Huxley. “A quantitative description of membrane current and its application toconduction and excitation in nerve.” The Journal of physiology 117.4 (1952): 500.Kistler, Werner M., Wulfram Gerstner, and J. Leo van Hemmen. “Reduction of the Hodgkin-Huxley equations to asingle-variable threshold model.” Neural computation 9.5 (1997): 1015-1045.- Parameters:
name – the string name of this cell
n_units – number of cellular entities (neural population size)
tau_v – membrane time constant (Default: 1 ms)
resist_m – membrane resistance value
v_Na – sodium reversal potential
v_K – potassium reversal potential
v_L – leak reversal potential
g_Na – sodium (Na) conductance per unit area
g_K – potassium (K) conductance per unit area
g_L – leak conductance per unit area
thr – voltage/membrane threshold (to obtain action potentials in terms of binary spikes/pulses)
spike_reset – if True, once voltage crosses threshold, then dynamics of voltage and recovery are reset/snapped to v_reset which has a default value of 0 mV (Default: False)
v_reset – voltage value to reset to after a spike (in mV) (Default: 0 mV)
integration_type –
type of integration to use for this cell’s dynamics; current supported forms include “euler” (Euler/RK-1 integration), “midpoint” or “rk2” (midpoint method/RK-2 integration), or “rk4” (RK-4 integration) (Default: “euler”)
- Note:
setting the integration type to the midpoint or rk4 method will increase the accuracy of the estimate of the cell’s evolution at an increase in computational cost (and simulation time)
ngclearn.components.neurons.spiking.izhikevichCell module
- class ngclearn.components.neurons.spiking.izhikevichCell.IzhikevichCell(*args, **kwargs)[source]
Bases:
JaxComponentA 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_mtau_w * dw/dt = (v * b - w), where tau_w = 1/a— Cell Input Compartments: —j - electrical current input (takes in external signals)— Cell State Compartments: —v - membrane potential/voltage statew - recovery variable statekey - JAX PRNG key— Cell Output Compartments: —s - emitted binary spikes/action potentialstols - time-of-last-spikeReferences:Izhikevich, Eugene M. “Simple model of spiking neurons.” IEEE Transactionson 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=4Chattering neurons:v_reset = -50, w_reset = 2Fast spiking neurons:tau_w = 10Low-threshold spiking neurons:tau_w = 10, coupling_factor = 0.25, w_reset = 2Resonator 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)
resist_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 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)
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 accuracy of the estimate of the cell’s evolution at an increase in computational cost (and simulation time)
ngclearn.components.neurons.spiking.quadLIFCell module
- class ngclearn.components.neurons.spiking.quadLIFCell.QuadLIFCell(*args, **kwargs)[source]
Bases:
LIFCellA spiking cell based on quadratic leaky integrate-and-fire (LIF) neuronal dynamics. Note that QuadLIFCell is a child of LIFCell and inherits its main set of routines, only overriding its dynamics in advance().
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 accumulationV_c - critical voltage (value)— Cell Input Compartments: —j - electrical current input (takes in external signals)— Cell State Compartments: —v - membrane potential/voltage staterfr - (relative) refractory variable statethr_theta - homeostatic/adaptive threshold increment statekey - JAX PRNG key— Cell Output Compartments: —s - emitted binary spikes/action potentialss_raw - raw spike signals before post-processing (only if one_spike = True, else s_raw = s)tols - time-of-last-spike- Parameters:
name – the string name of this cell
n_units – number of cellular entities (neural population size)
tau_m – membrane time constant
resist_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 (in mV) (i.e., variable name - a0)
tau_theta – homeostatic threshold time constant
theta_plus – physical increment to be applied to any threshold value if a spike was emitted
refract_time – 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
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 accuracy of the estimate of the cell’s evolution at an increase in computational cost (and simulation time)
surrogate_type –
type of surrogate function to use for approximating a partial derivative of this cell’s spikes w.r.t. its voltage/current (default: “straight_through”)
- Note:
surrogate options available include: “straight_through” (straight-through estimator), “triangular” (triangular estimator), “arctan” (arc-tangent estimator), and “secant_lif” (the LIF-specialized secant estimator)
v_min – minimum voltage to clamp dynamics to (Default: None)
ngclearn.components.neurons.spiking.sLIFCell module
- class ngclearn.components.neurons.spiking.sLIFCell.SLIFCell(*args, **kwargs)[source]
Bases:
JaxComponentA 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.)
— Cell Input Compartments: —j - electrical current input (takes in external signals)— Cell State Compartments: —v - membrane potential/voltage staterfr - (relative) refractory variable statethr - (adaptive) threshold statekey - JAX PRNG key— Cell Output Compartments: —s - emitted binary spikes/action potentialssurrogate - state of surrogate function output signals (currently, the secant LIF estimator)tols - time-of-last-spikeReference:Samadi, Arash, Timothy P. Lillicrap, and Douglas B. Tweed. “Deep learning withdynamic 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
resist_m – membrane resistance value
thr – base value for adaptive thresholds (initial condition for per-cell thresholds) that govern short-term plasticity
resist_inh – 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
thr_gain – how much adaptive thresholds increment by
thr_leak – how much adaptive thresholds are decremented/decayed by
refract_time – relative refractory period time (ms; Default: 1 ms)
rho_b – threshold sparsity factor (Default: 0); note that setting rho_b > 0 will force the adaptive threshold to follow dynamics that ignore thr_grain and thr_leak
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
batch_size – batch size dimension of this cell (Default: 1)