AdEx

class AdEx(shape: tuple[int, ...] | int, step_time: float, *, rest_v: float, rheobase_v: float, sharpness: float, reset_v: float, thresh_v: float, refrac_t: float, tc_membrane: float, tc_adaptation: float | tuple[float, ...], voltage_coupling: 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: AdaptiveCurrentMixin, VoltageMixin, SpikeRefractoryMixin, InfernoNeuron

Simulation of adaptive exponential integrate-and-fire (AdEx) neuron dynamics.

Implemented as an approximation using Euler’s method.

\[\begin{split}\begin{align*} V_m(t + \Delta t) &= \frac{\Delta t}{\tau_m} \left[- \left[V_m(t) - V_\text{rest}\right] + \Delta_T \exp \left(\frac{V_m(t) - V_T}{\Delta_T}\right) + R_mI(t) \right]+ V_m(t) \\ I(t) &= I_x(t) - \sum_k w_k(t) \\ w_k(t + \Delta t) &= \frac{\Delta t}{\tau_k}\left[ a_k \left[ V_m(t) - V_\text{rest} \right] - w_k(t) \right] + w_k(t) \\ \end{align*}\end{split}\]

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

\[\begin{split}\begin{align*} V_m(t) &\leftarrow V_\text{reset} \\ w_k(t) &\leftarrow w_k(t) + b_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}\).

  • rheobase_v (float) – membrane potential difference approaching the potential at which potential rapidly increases, \(V_T\), in \(\text{mV}\).

  • sharpness (float) – steepness of the natural increase in membrane potential above the rheobase voltage, \(\Delta_T\), in \(\text{mV}\).

  • reset_v (float) – membrane voltage after an action potential is generated, \(V_\text{reset}\), in \(\text{mV}\).

  • thresh_v (float) – membrane voltage at which action potentials are generated, 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}\).

  • voltage_coupling (float | tuple[float, ...]) – strength of coupling to membrane voltage, \(a_k\), in \(\mu\text{S}\).

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

  • 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 Adaptive Exponential Integrate-and-Fire (AdEx) 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_x(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.