GifRef#
- class brainpy.state.GifRef(in_size, R=Quantity(20., "ohm"), tau=Quantity(20., "ms"), tau_ref=Quantity(1.7, "ms"), V_rest=Quantity(-70., "mV"), V_reset=Quantity(-70., "mV"), V_th_inf=Quantity(-50., "mV"), V_th_reset=Quantity(-60., "mV"), V_th_initializer=Constant(value=-50. mV), a=Quantity(0., "kHz"), b=Quantity(0.01, "kHz"), k1=Quantity(0.2, "kHz"), k2=Quantity(0.02, "kHz"), R1=0.0, R2=1.0, A1=Quantity(0., "mA"), A2=Quantity(0., "mA"), V_initializer=Constant(value=-70. mV), I1_initializer=Constant(value=0. mA), I2_initializer=Constant(value=0. mA), spk_fun=ReluGrad(alpha=0.3, width=1.0), spk_reset='soft', ref_var=False, name=None)#
Generalized Integrate-and-Fire neuron model with refractory mechanism.
This model extends Gif by adding an absolute refractory period during which the neuron cannot fire. This creates more realistic firing patterns and prevents unrealistic high-frequency firing.
- Parameters:
in_size (
Size) – Size of the input to the neuron.R (
ArrayLike, default20. * u.ohm) – Membrane resistance.tau (
ArrayLike, default20. * u.ms) – Membrane time constant.tau_ref (
ArrayLike, default1.7 * u.ms) – Absolute refractory period duration.V_rest (
ArrayLike, default-70. * u.mV) – Resting potential.V_reset (
ArrayLike, default-70. * u.mV) – Reset potential after spike.V_th_inf (
ArrayLike, default-50. * u.mV) – Target value of threshold potential updating.V_th_reset (
ArrayLike, default-60. * u.mV) – Free parameter, should be larger than V_reset.V_th_initializer (
Callable) – Initializer for the threshold potential.a (
ArrayLike, default0. / u.ms) – Coefficient describes dependence of V_th on membrane potential.b (
ArrayLike, default0.01 / u.ms) – Coefficient describes V_th update.k1 (
ArrayLike, default0.2 / u.ms) – Constant of I1.k2 (
ArrayLike, default0.02 / u.ms) – Constant of I2.R1 (
ArrayLike, default0.) – Free parameter.R2 (
ArrayLike, default1.) – Free parameter.A1 (
ArrayLike, default0. * u.mA) – Free parameter.A2 (
ArrayLike, default0. * u.mA) – Free parameter.V_initializer (
Callable) – Initializer for the membrane potential state.I1_initializer (
Callable) – Initializer for internal current I1.I2_initializer (
Callable) – Initializer for internal current I2.spk_fun (
Callable, defaultsurrogate.ReluGrad()) – Surrogate gradient function.spk_reset (
str, default'soft') – Reset mechanism after spike generation.ref_var (
bool, defaultFalse) – Whether to expose a boolean refractory state variable.name (
str, optional) – Name of the neuron layer.
- V#
Membrane potential.
- Type:
HiddenState
- I1#
Internal current 1.
- Type:
HiddenState
- I2#
Internal current 2.
- Type:
HiddenState
- V_th#
Spiking threshold potential.
- Type:
HiddenState
- last_spike_time#
Last spike time recorder.
- Type:
ShortTermState
- refractory#
Neuron refractory state (if ref_var=True).
- Type:
HiddenState
Notes
Combines Gif model’s rich dynamics with absolute refractory period.
During refractory period, all state variables are held at reset values.
Set ref_var=True to track refractory state as a boolean variable.
More biologically realistic than Gif without refractory mechanism.
Can still exhibit diverse firing patterns: regular, bursting, adaptation.
Refractory period prevents unrealistically high firing rates.
References
Examples
>>> import brainpy >>> import brainstate >>> import saiunit as u >>> # Create a GifRef neuron layer with refractory period >>> gif_ref = brainpy.state.GifRef(10, tau=20*u.ms, tau_ref=2.0*u.ms, ... k1=0.2/u.ms, k2=0.02/u.ms, ref_var=True) >>> # Initialize the state >>> gif_ref.init_state(batch_size=1)
- get_spike(V=None, V_th=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.