GLIF2

class GLIF2(shape: tuple[int, ...] | int, step_time: float, *, rest_v: float, reset_v_add: float, reset_v_mul: float, thresh_eq_v: float, refrac_t: float, tc_membrane: float, rc_adaptation: float | tuple[float, ...], spike_increment: float | tuple[float, ...], resistance: float = 1.0, batch_size: int = 1, batch_reduction: Callable[[Tensor, tuple[int, ...]], Tensor] | None = None)[source]

Bases: AdaptiveThresholdMixin, VoltageMixin, SpikeRefractoryMixin, InfernoNeuron

Simulation of generalized leaky integrate-and-fire 2 (GLIF2) neuron dynamics.

\[\begin{split}\begin{align*} V_m(t + \Delta t)&= \left[ V_m(t) - V_\text{rest} - R_mI(t) \right] \exp\left(-\frac{t}{\tau_m}\right) + V_\text{rest} + R_mI(t) \\ \Theta(t) &= \Theta_\infty + \sum_k \theta_k(t) \\ \theta_k(t + \Delta t) &= \theta_k(t) \exp\left(-\lambda_k \Delta t\right) \end{align*}\end{split}\]

If a spike was generated at time \(t\), then.

\[\begin{split}\begin{align*} V_m(t) &\leftarrow V_\text{rest} + m_v \left[ V_m(t) - V_\text{rest} \right] - b_v \\ \theta_k(t) &\leftarrow \theta_k(t) + d_k \end{align*}\end{split}\]
Parameters:
  • shape (tuple[int, ...] | int) – shape of the group of neurons being simulated.

  • step_time (float) – length of a simulation time step, \(\Delta t\), in \(\text{ms}\).

  • rest_v (float) – membrane potential difference at equilibrium, \(V_\text{rest}\), in \(\text{mV}\).

  • reset_v_add (float) – additive parameter controlling reset voltage, \(b_v\), in \(\text{mV}\).

  • reset_v_mul (float) – multiplicative parameter controlling reset voltage, \(m_v\), unitless.

  • thresh_eq_v (float) – equilibrium of the firing threshold, \(\Theta_\infty\), in \(\text{mV}\).

  • refrac_t (float) – length the absolute refractory period, in \(\text{ms}\).

  • tc_membrane (float) – time constant of exponential decay for membrane voltage, \(\tau_m\), in \(\text{ms}\).

  • rc_adaptation (float | tuple[float, ...]) – rate constant of exponential decay for threshold adaptations, \(\lambda_k\), in \(\text{ms}^{-1}\).

  • spike_increment (float | tuple[float, ...]) – amount by which the adaptive threshold is increased after a spike, \(d_k\), in \(\text{mV}\).

  • resistance (float, optional) – resistance across the cell membrane, \(R_m\), in \(\text{M}\Omega\). Defaults to 1.0.

  • batch_size (int, optional) – size of input batches for simulation. Defaults to 1.

  • batch_reduction (Callable[[torch.Tensor, tuple[int, ...]], torch.Tensor] | None) – function to reduce adaptation updates over the batch dimension, torch.mean() when None. Defaults to None.

Note

batch_reduction can be one of the functions in PyTorch including but not limited to torch.sum(), torch.mean(), and torch.amax(). A custom function with similar behavior can also be passed in. Like with the included function, it should not keep the original dimensions by default.

See also

For more details and references, visit Generalized Leaky Integrate-and-Fire 2 (GLIF2) in the zoo.

clear(keep_adaptations: bool = True, **kwargs) None[source]

Resets neurons to their resting state.

Parameters:

keep_adaptations (bool, optional) – if learned adaptations should be preserved. Defaults to True.

property dt: float

Length of the simulation time step, in milliseconds.

Parameters:

value (float) – new simulation time step length.

Returns:

present simulation time step length.

Return type:

float

forward(inputs: Tensor, adapt: bool | None = None, refrac_lock: bool = True, **kwargs) Tensor[source]

Runs a simulation step of the neuronal dynamics.

Parameters:
  • inputs (torch.Tensor) – presynaptic currents, \(I(t)\), in \(\text{nA}\).

  • adapt (bool | None, optional) – if adaptations should be updated based on this step. Defaults to None.

  • refrac_lock (bool, optional) – if membrane voltages should be fixed while in the refractory period. Defaults to True.

Returns:

if the corresponding neuron generated an action potential.

Return type:

torch.Tensor

Note

When adapt is set to None, adaptations will be updated when the neuron is in training mode but not when it is in evaluation mode.