LIF Neuron Playground

A leaky integrate-and-fire neuron adds up incoming input, loses a little charge every step, and fires a spike when it crosses a threshold. Move the sliders and see what happens.

Membrane potential Threshold Spike
Charge added each step. More input means more spikes.
Share of charge kept each step. 1.0 means no leak.
Level that triggers a spike. Higher means fewer spikes.

How it works

On every time step the neuron does this:

v = beta * v + input;
if (v >= threshold) {
  spike = true;
  v = 0;
}

The neuron adds the input to v, keeps only a fraction (beta) of what it had before, and resets to zero after it fires.

Try lowering the input until input / (1 - beta) is smaller than the threshold. The leak then cancels the input and the neuron never fires. That is why spiking neurons only react to strong or sustained signals, and why neuromorphic chips can use so little power when nothing is happening.

This is a simplified version of the model used in snnTorch, Brian2 and Nengo.