QuaIF#
- class brainpy.state.QuaIF(in_size, R=Quantity(1., "ohm"), tau=Quantity(10., "ms"), V_th=Quantity(-30., "mV"), V_reset=Quantity(-68., "mV"), V_rest=Quantity(-65., "mV"), V_c=Quantity(-50., "mV"), c=Quantity(0.07, "1 / mV"), V_initializer=Constant(value=-65. mV), spk_fun=ReluGrad(alpha=0.3, width=1.0), spk_reset='soft', name=None)#
Quadratic Integrate-and-Fire (QuaIF) neuron model.
This model extends the basic integrate-and-fire neuron by adding a quadratic nonlinearity in the voltage dynamics. The quadratic term creates a soft spike initiation, making the model more biologically realistic than the linear IF model.
The model is characterized by the following differential equation:
\[ \tau \frac{dV}{dt} = c(V - V_{rest})(V - V_c) + R \cdot I(t) \]Spike condition: If \(V \geq V_{th}\): emit spike and reset \(V = V_{reset}\)
- Parameters:
in_size (
Size) – Size of the input to the neuron.R (
ArrayLike, default1. * u.ohm) – Membrane resistance.tau (
ArrayLike, default10. * u.ms) – Membrane time constant.V_th (
ArrayLike, default-30. * u.mV) – Firing threshold voltage.V_reset (
ArrayLike, default-68. * u.mV) – Reset voltage after spike.V_rest (
ArrayLike, default-65. * u.mV) – Resting membrane potential.V_c (
ArrayLike, default-50. * u.mV) – Critical voltage for spike initiation. Must be larger than V_rest.c (
ArrayLike, default0.07 / u.mV) – Coefficient describing membrane potential update. Larger than 0.V_initializer (
Callable) – Initializer for the membrane potential state.spk_fun (
Callable, defaultsurrogate.ReluGrad()) – Surrogate gradient function for the spike generation.spk_reset (
str, default'soft') – Reset mechanism after spike generation.name (
str, optional) – Name of the neuron layer.
- V#
Membrane potential.
- Type:
HiddenState
See also
AdQuaIFAdaptive quadratic integrate-and-fire.
AdQuaIFRefAdaptive quadratic IF with refractory period.
ExpIFExponential integrate-and-fire (alternative nonlinear model).
Notes
The quadratic nonlinearity provides a more realistic spike initiation compared to LIF.
The critical voltage V_c determines the onset of spike generation.
When V approaches V_c, the quadratic term causes rapid acceleration toward threshold.
This model can exhibit Type I excitability (continuous f-I curve) [1].
References
Examples
>>> import brainpy >>> import brainstate >>> import saiunit as u >>> # Create a QuaIF neuron layer with 10 neurons >>> quaif = brainpy.state.QuaIF(10, tau=10*u.ms, V_th=-30*u.mV, ... V_c=-50*u.mV) >>> # Initialize the state >>> quaif.init_state(batch_size=1) >>> # Apply an input current and update the neuron state >>> spikes = quaif.update(x=2.5*u.mA)
- get_spike(V=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_funto 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.