ALIF¶
- class ALIF(shape: tuple[int, ...] | int, step_time: float, *, rest_v: float, reset_v: float, thresh_eq_v: float, refrac_t: float, tc_membrane: float, tc_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 adaptive leaky integrate-and-fire (ALIF) neuron dynamics.
ALIF is implemented as a step of leaky integrate-and-fire applying existing adaptations, using linear spike-dependent adaptive thresholds, then updating those adaptations for the next time step.
\[\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(-\frac{\Delta t}{\tau_k}\right) \end{align*}\end{split}\]If a spike was generated at time \(t\), then.
\[\begin{split}\begin{align*} V_m(t) &\leftarrow V_\text{reset} \\ \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 (float) – membrane voltage after an action potential is generated, \(V_\text{reset}\), in \(\text{mV}\).
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}\).
tc_adaptation (float | tuple[float, ...]) – time constant of exponential decay for threshold adaptations, \(\tau_k\), in \(\text{ms}\).
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()
whenNone
. Defaults toNone
.
Note
batch_reduction
can be one of the functions in PyTorch including but not limited totorch.sum()
,torch.mean()
, andtorch.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 Adaptive Leaky Integrate-and-Fire (ALIF) 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
.
- 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:
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.