Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Here, we present one of the key strengths of this online SNN book - Interactive Visualizations! Such interactive visualizations - accompanied with their code - can help you build a clear and thorough understanding of the core concepts of SNNs. You can engage with these visualizations / demonstrations right here to quickly learn the presented concept’s intricacies and the effects of its variable parameters.

Try moving the sliders of the animation of Leaky Integrate & Fire (LIF) neuron below!


1Example of Leaky Integrate & Fire neuron

In the example above, we simulate a LIF neuron to demonstrate its interactive visualization. We now describe its dynamics; following is the discrete-time voltage equation of a typical LIF neuron:

V[t]=(1vdecay)V[t1]+I[t]V[t] = (1-v_\text{decay})V[t-1] + I[t]

where V[t]V[t] is LIF’s voltage state, I[t]I[t] is its input current, and vdecayv_\text{decay} is its voltage decay parameter. When V[t]V[t] reaches or crosses a voltage threshold (say VthrV_\text{thr}), the LIF neuron:

S[t]=Θ(V[t]Vthr)S[t] = \Theta(V[t] - V_\text{thr})
V[t]=0V[t] = 0

1.1LIF neuron visualization

If you move the sliders in the animation above, you will observe the following behaviors:

Keeping Input Current (I) fixed:

Similarly, keeping the Voltage Decay fixed:

1.2Code

Our visualization relies on the DynSim library, developed by the editors of the SNN book. It works as a plugin to the platform that we have used to build this book: Jupyter Book. Users and contributors using DynSim can simply write the Python code in a step() function as below. Following is the example code for the LIF visualization above.

import numpy as np

def step(x, state, p):
  """ 
  Leaky Integrate & Fire neuron.

  Args:
    x: Input current `I` from the slider.
    state: State variable dict, i.e., `state["V"]`.
    p: Other parameters dict, i.e., `p[v_decay]`.

  Returns:
    Tuple of (new `V` value, new `state` dict).
  """
  
  V_new = (1 - p["v_decay"])*state["V"] + x # Update Voltage.

  S = 0
  if V_new > 1.0:
    S = 1
    V_new = 0.0

  return (V_new, {"V": V_new, "S": S})

And that is it! We cannot wait to see what you will build with it.