ALIF#

class brainpy.state.ALIF(in_size, R=Quantity(1., "ohm"), tau=Quantity(5., "ms"), tau_a=Quantity(100., "ms"), V_th=Quantity(1., "mV"), V_reset=Quantity(0., "mV"), V_rest=Quantity(0., "mV"), beta=Quantity(0.1, "mV"), spk_fun=ReluGrad(alpha=0.3, width=1.0), spk_reset='soft', V_initializer=Constant(value=0. mV), a_initializer=Constant(value=0.0), name=None)#

Adaptive Leaky Integrate-and-Fire (ALIF) neuron model.

This class implements the Adaptive Leaky Integrate-and-Fire neuron model, which extends the basic LIF model by adding an adaptation variable. This adaptation mechanism increases the effective firing threshold after each spike, allowing the neuron to exhibit spike-frequency adaptation - a common feature in biological neurons that reduces firing rate during sustained stimulation.

The model is characterized by the following differential equations:

\[ \tau \frac{dV}{dt} = -(V - V_{rest}) + R \cdot I(t) \]

\[ \tau_a \frac{da}{dt} = -a \]

Spike condition: If \(V \geq V_{th} + \beta \cdot a\): emit spike, set \(V = V_{reset}\), and increment \(a = a + 1\)

Parameters:
  • in_size (Size) – Size of the input to the neuron.

  • R (ArrayLike, default 1. * u.ohm) – Membrane resistance.

  • tau (ArrayLike, default 5. * u.ms) – Membrane time constant.

  • tau_a (ArrayLike, default 100. * u.ms) – Adaptation time constant (typically much longer than tau).

  • V_th (ArrayLike, default 1. * u.mV) – Base firing threshold voltage.

  • V_reset (ArrayLike, default 0. * u.mV) – Reset voltage after spike.

  • V_rest (ArrayLike, default 0. * u.mV) – Resting membrane potential.

  • beta (ArrayLike, default 0.1 * u.mV) – Adaptation coupling parameter that scales the effect of the adaptation variable.

  • spk_fun (Callable) – Surrogate gradient function for the non-differentiable spike generation.

  • spk_reset (str, default 'soft') –

    Reset mechanism after spike generation:

    • ’soft’: subtract threshold V = V - V_th

    • ’hard’: strict reset using stop_gradient

  • V_initializer (Callable) – Initializer for the membrane potential state.

  • a_initializer (Callable) – Initializer for the adaptation variable.

  • name (str, optional) – Name of the neuron layer.

V#

Membrane potential.

Type:

HiddenState

a#

Adaptation variable that increases after each spike and decays exponentially.

Type:

HiddenState

See also

LIF

Standard LIF without adaptation.

LIFRef

LIF with refractory period.

AdExIF

Adaptive exponential integrate-and-fire.

Notes

  • The adaptation variable ‘a’ increases by 1 with each spike and decays exponentially with time constant tau_a between spikes.

  • The effective threshold increases by beta*a, making it progressively harder for the neuron to fire when it has recently been active.

  • This adaptation mechanism creates spike-frequency adaptation [2], allowing the neuron to respond strongly to input onset but then reduce its firing rate even if the input remains constant.

  • The adaptation time constant tau_a is typically much larger than the membrane time constant tau, creating a longer-lasting adaptation effect.

  • The time-dependent dynamics are integrated using an exponential Euler method.

  • For detailed analysis of adaptive integrate-and-fire models, see [1] and [3].

References

Examples

>>> import brainpy
>>> import brainstate
>>> import saiunit as u
>>> # Create an ALIF neuron layer with 10 neurons
>>> alif = brainpy.state.ALIF(10, tau=10*u.ms, tau_a=200*u.ms,
...                           beta=0.2*u.mV)
>>> # Initialize the state
>>> alif.init_state(batch_size=1)
>>> # Apply an input current and update the neuron state
>>> spikes = alif.update(x=1.5*u.mA)
get_spike(V=None, a=None)[source]#

Generate spikes based on neuron state variables.

This abstract method must be implemented by subclasses to define the spike generation mechanism. The method should use the surrogate gradient function self.spk_fun to enable gradient-based learning.

Parameters:
  • *args – Positional arguments (typically state variables like membrane potential)

  • **kwargs – Keyword arguments

Returns:

Binary spike tensor where 1 indicates a spike and 0 indicates no spike.

Return type:

ArrayLike

Raises:

NotImplementedError – If the subclass does not implement this method.

init_state(batch_size=None, **kwargs)[source]#

State initialization function.

reset_state(batch_size=None, **kwargs)[source]#

State resetting function.