iaf_cond_alpha#
- class brainpy.state.iaf_cond_alpha(in_size, E_L=Quantity(-70., "mV"), C_m=Quantity(250., "pF"), t_ref=Quantity(2., "ms"), V_th=Quantity(-55., "mV"), V_reset=Quantity(-60., "mV"), E_ex=Quantity(0., "mV"), E_in=Quantity(-85., "mV"), g_L=Quantity(16.6667, "nS"), tau_syn_ex=Quantity(0.2, "ms"), tau_syn_in=Quantity(2., "ms"), I_e=Quantity(0., "pA"), gsl_error_tol=0.001, V_initializer=Constant(value=-70. mV), g_ex_initializer=Constant(value=0. nS), g_in_initializer=Constant(value=0. nS), spk_fun=ReluGrad(alpha=0.3, width=1.0), spk_reset='hard', ref_var=False, name=None)#
Leaky integrate-and-fire model with alpha-shaped conductance synapses.
Description
iaf_cond_alphais a conductance-based leaky integrate-and-fire neuron withhard threshold,
fixed absolute refractory period,
alpha-shaped excitatory and inhibitory synaptic conductances (second-order kinetics),
no adaptation variables.
This implementation follows NEST
iaf_cond_alphadynamics and update order, using NEST C++ model behavior as the source of truth.1. Membrane Potential and Synaptic Currents
The membrane potential evolves according to
\[\frac{dV_\mathrm{m}}{dt} = \frac{-g_\mathrm{L}(V_\mathrm{m}-E_\mathrm{L}) - I_\mathrm{syn} + I_\mathrm{e} + I_\mathrm{stim}} {C_\mathrm{m}}\]with
\[I_\mathrm{syn} = I_{\mathrm{syn,ex}} + I_{\mathrm{syn,in}} = g_\mathrm{ex}(V_\mathrm{m}-E_\mathrm{ex}) + g_\mathrm{in}(V_\mathrm{m}-E_\mathrm{in}) .\]2. Alpha-Shaped Conductance Kinetics
Alpha conductances use two coupled state variables per channel:
\[\frac{d\,dg_\mathrm{ex}}{dt} = -\frac{dg_\mathrm{ex}}{\tau_{\mathrm{syn,ex}}}, \qquad \frac{d g_\mathrm{ex}}{dt} = dg_\mathrm{ex} - \frac{g_\mathrm{ex}}{\tau_{\mathrm{syn,ex}}},\]\[\frac{d\,dg_\mathrm{in}}{dt} = -\frac{dg_\mathrm{in}}{\tau_{\mathrm{syn,in}}}, \qquad \frac{d g_\mathrm{in}}{dt} = dg_\mathrm{in} - \frac{g_\mathrm{in}}{\tau_{\mathrm{syn,in}}}.\]A presynaptic spike with weight \(w\) causes an instantaneous jump at the end of the simulation step. Positive/negative weights map to excitatory/inhibitory channels:
\[w > 0 \Rightarrow dg_\mathrm{ex} \leftarrow dg_\mathrm{ex} + \frac{e}{\tau_{\mathrm{syn,ex}}} w,\]\[w < 0 \Rightarrow dg_\mathrm{in} \leftarrow dg_\mathrm{in} + \frac{e}{\tau_{\mathrm{syn,in}}} |w|.\]The normalization factor \(e/\tau\) ensures the conductance peak matches the weight magnitude (in nS).
3. Spike Emission and Refractory Mechanism
A spike is emitted when \(V_\mathrm{m} \ge V_\mathrm{th}\) at the end of a simulation step. On spike:
\(V_\mathrm{m}\) is reset to \(V_\mathrm{reset}\),
refractory counter is set to \(\lceil t_\mathrm{ref}/dt \rceil\),
spike time is recorded as \(t + dt\).
During absolute refractory period:
effective membrane potential in current computation is clamped to \(V_\mathrm{reset}\),
\(dV_\mathrm{m}/dt = 0\),
conductances continue to decay.
4. Numerical Integration and Update Order
NEST integrates this model with adaptive RKF45. This implementation mirrors that behavior with an RKF45(4,5) integrator and persistent internal step size. The discrete-time update order is:
Integrate continuous dynamics on \((t, t+dt]\) using RKF45 with adaptive substeps.
Apply refractory countdown / threshold test / reset and spike emission.
Add synaptic conductance jumps from spike inputs arriving this step.
Store external current input as \(I_\mathrm{stim}\) for the next step.
The one-step delayed application of current input (
I_stimbuffer) is intentional and matches NEST’s ring-buffer update semantics.- Parameters:
in_size (
tupleofintorint) – Shape of the neuron population. Can be an integer for 1D populations or a tuple for multi-dimensional populations.E_L (
ArrayLike, optional) – Leak reversal potential \(E_\mathrm{L}\). Default: -70 mV.C_m (
ArrayLike, optional) – Membrane capacitance \(C_\mathrm{m}\). Must be strictly positive. Default: 250 pF.t_ref (
ArrayLike, optional) – Absolute refractory period \(t_\mathrm{ref}\). Must be non-negative. Default: 2 ms.V_th (
ArrayLike, optional) – Spike threshold \(V_\mathrm{th}\). Must be larger thanV_reset. Default: -55 mV.V_reset (
ArrayLike, optional) – Reset potential \(V_\mathrm{reset}\). Must be smaller thanV_th. Default: -60 mV.E_ex (
ArrayLike, optional) – Excitatory reversal potential \(E_\mathrm{ex}\). Default: 0 mV.E_in (
ArrayLike, optional) – Inhibitory reversal potential \(E_\mathrm{in}\). Default: -85 mV.g_L (
ArrayLike, optional) – Leak conductance \(g_\mathrm{L}\). Must be strictly positive. Default: 16.6667 nS (yields \(\tau_\mathrm{m} = 15\) ms with defaultC_m).tau_syn_ex (
ArrayLike, optional) – Excitatory alpha time constant \(\tau_{\mathrm{syn,ex}}\). Must be strictly positive. Default: 0.2 ms.tau_syn_in (
ArrayLike, optional) – Inhibitory alpha time constant \(\tau_{\mathrm{syn,in}}\). Must be strictly positive. Default: 2.0 ms.I_e (
ArrayLike, optional) – Constant external current \(I_\mathrm{e}\). Default: 0 pA.gsl_error_tol (
ArrayLike, optional) – Unitless local RKF45 error tolerance, broadcastable and strictly positive. Default: 1e-3.V_initializer (
Callable, optional) – Initializer for membrane potential. Default: Constant(-70 mV).g_ex_initializer (
Callable, optional) – Initializer for excitatory conductance. Default: Constant(0 nS).g_in_initializer (
Callable, optional) – Initializer for inhibitory conductance. Default: Constant(0 nS).spk_fun (
Callable, optional) – Surrogate gradient function for spike generation (differentiable approximation). Default: ReluGrad().spk_reset (
str, optional) – Spike reset mode.'hard'uses stop_gradient (matches NEST behavior),'soft'allows gradients through reset. Default:'hard'.ref_var (
bool, optional) – If True, exposerefractorystate variable as boolean indicator. Default: False.name (
str, optional) – Name of the neuron group.
Parameter Mapping
Parameter
Default
Math equivalent
in_size(required)
–
E_L-70 mV
\(E_\mathrm{L}\)
C_m250 pF
\(C_\mathrm{m}\)
t_ref2 ms
\(t_\mathrm{ref}\)
V_th-55 mV
\(V_\mathrm{th}\)
V_reset-60 mV
\(V_\mathrm{reset}\)
E_ex0 mV
\(E_\mathrm{ex}\)
E_in-85 mV
\(E_\mathrm{in}\)
g_L16.6667 nS
\(g_\mathrm{L}\)
tau_syn_ex0.2 ms
\(\tau_{\mathrm{syn,ex}}\)
tau_syn_in2.0 ms
\(\tau_{\mathrm{syn,in}}\)
I_e0 pA
\(I_\mathrm{e}\)
gsl_error_tol1e-3
–
V_initializerConstant(-70 mV)
–
g_ex_initializerConstant(0 nS)
–
g_in_initializerConstant(0 nS)
–
spk_funReluGrad()
–
spk_reset'hard'–
ref_varFalse–
State Variables
State variable
Description
VMembrane potential \(V_\mathrm{m}\)
dg_exExcitatory alpha auxiliary state
g_exExcitatory conductance \(g_\mathrm{ex}\)
dg_inInhibitory alpha auxiliary state
g_inInhibitory conductance \(g_\mathrm{in}\)
last_spike_timeLast spike time (recorded at \(t+dt\))
refractory_step_countRemaining refractory grid steps
integration_stepInternal RKF45 step-size state (persistent)
I_stimBuffered current applied in next step
refractoryOptional boolean refractory indicator (if
ref_var=True)Sends:
SpikeEvent(conceptually; represented as returned spike tensor fromupdate).Receives: Signed spike-weight conductance increments through
add_delta_input. - External current input throughxinupdate()(one-step delayed).- Raises:
ValueError – If
V_reset >= V_th,C_m <= 0,t_ref < 0, or any time constants are non-positive.
Notes
Defaults follow NEST C++ source for
iaf_cond_alpha(models/iaf_cond_alpha.h/.cpp).Synaptic spike weights are interpreted in conductance units (nS), with positive/negative sign selecting excitatory/inhibitory channel.
The alpha shape produces a smoother conductance transient than single exponentials, peaking at \(t = \tau\) after a spike.
During refractory period, the effective voltage used for current computation is clamped, but the actual
Vstate continues to be updated (remains at reset value).
References
See also
iaf_cond_expConductance-based LIF with exponential synapses
iaf_psc_alphaCurrent-based LIF with alpha synapses
iaf_psc_deltaCurrent-based LIF with delta synapses
Examples
Create a population of 100 conductance-based neurons:
>>> import brainpy.state as bst >>> import saiunit as u >>> neurons = bst.iaf_cond_alpha( ... in_size=100, ... V_th=-50. * u.mV, ... tau_syn_ex=0.5 * u.ms, ... tau_syn_in=2.0 * u.ms ... )
- get_spike(V=None)[source]#
Compute differentiable spike output using surrogate gradient.
Applies the surrogate spike function to a normalized voltage to produce a continuous approximation of spike events suitable for gradient-based learning.
- Parameters:
V (
ArrayLike, optional) – Membrane potential to evaluate. If None, uses currentself.V.value. Shape must match neuron population shape.- Returns:
Spike output in [0, 1], where values close to 1 indicate spike events. Shape matches input voltage shape.
- Return type:
ArrayLike
Notes
The voltage is normalized to \((V - V_\mathrm{th}) / (V_\mathrm{th} - V_\mathrm{reset})\) before applying the surrogate function. This makes the surrogate function operate in a standardized range regardless of absolute voltage values.
- init_state(**kwargs)[source]#
Initialize all state variables.
Creates and initializes membrane potential, conductance states, refractory counters, integration step size, and optional refractory indicator.
- Parameters:
**kwargs (
dict) – Additional keyword arguments (unused, for API compatibility).
Notes
V,g_ex,g_inare initialized using their respective initializers.dg_ex,dg_in(alpha auxiliary states) are initialized to zero.last_spike_timeis set to large negative value (-1e7 ms).refractory_step_countstarts at 0 (not in refractory period).integration_stepis initialized to the global timestepdt.I_stimbuffer starts at 0 pA.
- update(x=Quantity(0., 'pA'))[source]#
Advance neuron state by one simulation timestep.
Integrates ODEs, handles refractory period and spike emission, applies synaptic conductance jumps, and buffers external current for next step. This method implements the full NEST update semantics.
- Parameters:
x (
ArrayLike, optional) – External current input for this timestep (pA). Broadcasted to population shape. This input is buffered and applied in the next timestep (one-step delay) to match NEST ring-buffer semantics. Default: 0 pA.- Returns:
Differentiable spike output (values in [0, 1], shape matching population). Computed using surrogate gradient on pre-reset membrane potential.
- Return type:
ArrayLike
Notes
Update order (matching NEST):
Integrate ODEs: Use RKF45 to advance
V,dg_ex,g_ex,dg_in,g_inover(t, t+dt]withI_stimfrom previous step.Refractory/spike handling:
If in refractory period: clamp
VtoV_reset, decrement counter.Else if
V >= V_th: emit spike, resetVtoV_reset, set refractory counter.
Apply synaptic inputs: Add conductance jumps from incoming spikes (via
add_delta_input) todg_ex/dg_inwith alpha normalization.Buffer current input: Store
xintoI_stimfor next timestep.
The surrogate spike is computed from the pre-reset voltage to allow gradient flow through spike events during training.
Failure modes: If integration does not converge within
_MAX_ITERSiterations, the final state may be inaccurate. Reduce globaldtor check for extreme parameter values if this occurs.