Implementing MNIST classifiction on Loihi-2 Neuromorphic Chip -- both on Simulation Hardware and actual Physical Hardware (on INRC) through Lava library; a detailed tutorial can be found here.
The SLAYER network is trained on GPU first and then the correspondng Lava
network built from it is evaluated on the Loihi simulation (which runs on CPU),
as well as on the physical hardware (on INRC cloud). The SLAYER network is a
simple Dense-SNN
composed of two Hidden Layers (
This tutorial was evaluated on the following libraries:
lava-dl 0.5.0
lava-dnf 0.2.0
lava-loihi 0.6.0
lava-nc 0.9.0
lava-optimization 0.4.0
lava-peripherals 0.1.0
To execute this tutorial on your machine, you only need lava-dl
and lava-nc
which can be installed from
here. Do
note that these two libraries will enable only training and evaluation on
GPU/CPU.
To execute this tutorial on an actual Loihi hardware (on INRC), install rest of the above-mentioned libraries from your INRC account.
First train the SLAYER network using the following:
python train_eval_snn.py --n_tsteps=20 --epochs=20 --backend=GPU
The above will create and save a trained *.net
file that will be loaded and
ported to Loihi via netx
. As part of the above command's execution, SLAYER will
train and evaluate the Dense-SNN
on the entire set og training and test images.
Later, the saved *.net
file will be loaded and evaluated on
After training, you can simply evaluate it again on the Loihi-2 simulation hardware by executing the following:
python train_eval_snn.py --n_tsteps=32 --num_test_imgs=25 --backend=L2Sim
To evaluate on the actual Loihi-2 physical chip on INRC, execute the following:
SLURM=1 BOARD=ncl-ext-og-01 python train_eval_snn.py --n_tsteps=32 --num_test_imgs=25 --backend=L2Hw
Your results may vary slightly with mine in the tutorial. Feel free to comment there on my blog if you face any issues running my code in this repository. You can also find me on Discord at Open Neuromorphic.
The code in this repo is adapted from the Loihi tutorials on deploying MNIST trained network on Loihi and the Oxford Regression task: training on GPU and inference on Loihi. More details at: https://lava-nc.org