This repository contains code for training and evaluating a spiking neural network (SNN) with a spiking RNN region‑of‑interest (ROI) predictor, alongside a CNN baseline, on voxelised event‑based vision data.
This work forms part of a dissertation at the University of Manchester. It explores how SNNs can leverage ROI prediction to improve classification on event‑based vision datasets.
- Spiking RNN ROI predictor integrated with a LeNet‑style SNN
- CNN baseline for comparison
- Real‑time progress bars with
tqdmfor clear training and evaluation feedback - Class‑weighted loss to balance skewed class frequencies
- Evaluation scripts producing confusion matrices and classification reports
.
├── data # Dataset loaders and transforms
│ ├── datasets.py
│ └── transforms.py
├── models # Network definitions
│ ├── spiking_rnn_roi.py
│ ├── lenet_snn.py
│ └── cnn_baseline.py
├── scripts # Training and evaluation scripts
│ ├── train_snn.py
│ ├── train_cnn.py
│ └── evaluate.py
├── results # Saved models and output figures
│ ├── figures
│ └── reports
└── README.md
-
Clone this repository:
git clone https://github.com/yourusername/neuromorphic-classification.git cd neuromorphic-classification -
Create and activate a virtual environment.
-
Install dependencies:
pip install -r requirements.txt
- Download the NMNIST or DVS Gesture dataset.
- Update paths in
data/datasets.pyto point to your data directory. - The code converts events into 5D voxel tensors of shape
[batch, time, channels, height, width].
python scripts/train_snn.py \
--epochs 5 \
--batch-size 32 \
--lr 1e-3 \
--num-workers 2This script displays batch‑level progress using tqdm and saves the best model under results/.
python scripts/train_cnn.py \
--epochs 5 \
--batch-size 32 \
--lr 1e-3 \
--num-workers 2Run the evaluation script to generate confusion matrices and classification reports:
python scripts/evaluate.py \
--model-path results/snn_best.pth \
--dataset testThe script prints a classification report to the console and saves a confusion matrix plot in results/figures.
Training the SNN improved accuracy from around 17% to nearly 68% over five epochs. The confusion matrix highlighted bias towards certain classes, prompting the use of class weights.
- Explore alternative ROI predictor architectures
- Add event‑data augmentation strategies
- Investigate online learning and adaptive threshold techniques
This project is licensed under MIT.