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:
where is LIF’s voltage state, is its input current, and is its voltage decay parameter. When reaches or crosses a voltage threshold (say ), the LIF neuron:
produces a spike , which can be modeled as a Heaviside Step Function , i.e.,
and its voltage is hard reset to 0, i.e.,
1.1LIF neuron visualization¶
If you move the sliders in the animation above, you will observe the following behaviors:
Keeping Input Current (I) fixed:
If you decrease Voltage Decay, you will find that the frequency of spikes increases; this is because:
the Voltage (V) does not decay rapidly, and
it quickly crosses the voltage threshold (i.e., 1.0).
If you increase Voltage Decay, you will find that either the frequency of spikes decreases or the neuron does not spike at all; this is because:
the Voltage (V) either crosses the threshold late (due to increased decay), or
it never crosses the threshold (due to the decay being too much), thus, no spikes!
Similarly, keeping the Voltage Decay fixed:
If you increase the Input Current (I), you will observe that the frequency of spikes increases; this is because:
a higher Current (I) value is fed to the neuron, and
its Voltage (V) is updated by a large value,
thus, V quickly crosses the threshold
If you decrease the Input Current (I), you will observe that either the frequency of spikes decreases or the neuron does not spike at all; this is because:
a smaller Current (I) value is fed to the neuron, and
its Voltage (V) is updated by a small value,
thus, V either takes longer to cross the threshold, or
the update in V is too small to overcome the voltage decaying effect, thus no spikes!
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.