Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rethinking the Energy Efficiency of SNNs and ANNs: A Perspective from Neural Network Design

This repository contains two complementary parts of the SNN-vs-ANN study:

  • an analytical model for estimating and comparing ANN/SNN energy consumption and latency; and
  • SpikingJelly-based experiment scripts for training, conversion, inference, and spike-statistics collection on MNIST, Fashion-MNIST, and CIFAR-10 style workloads.

The code accompanies the paper "Rethinking the Energy Efficiency of SNNs and ANNs: A Perspective from Neural Network Design".

Repository Layout

.
├── analytical_model/          # Analytical energy/latency formulas and plotting helpers
├── data/                      # Small input data files used by selected analytical sweeps
├── docs/                      # Open-source checklist and maintenance notes
├── figures/                   # Paper and generated figures
└── spikingjelly_experiments/  # SNN/ANN training and conversion scripts

Installation

Create a Python environment and install the shared dependencies:

python -m pip install -r requirements.txt

For GPU experiments, install the PyTorch build that matches your CUDA version before installing the remaining packages.

The analytical model only needs NumPy, SciPy, pandas, Matplotlib, and openpyxl. The SpikingJelly experiments additionally require PyTorch, TorchVision, SpikingJelly, tqdm, and TensorBoard.

Analytical Model Quick Start

Run the default analytical examples:

python analytical_model/formulas.py

Expected output includes representative ANN CNN, rate-coded SNN CNN, and TTFS SNN CNN energy estimates, plus SNN/ANN energy ratios.

You can also import individual functions:

from analytical_model import formulas

ann_energy = formulas.ann_cnn(density=0.43)
rate_snn_energy = formulas.rate_cnn(density=0.41, timestep=5)
ttfs_snn_energy = formulas.ttfs_cnn(density=0.51, timestep=64)

print(rate_snn_energy / ann_energy)
print(ttfs_snn_energy / ann_energy)

Some analytical sweeps require optional data files from data/, such as firerate_ts.xlsx. The code searches the organized data directory automatically.

SpikingJelly Experiment Quick Start

The SpikingJelly scripts are in spikingjelly_experiments/. Run them from that directory so their relative data/ and logs/ paths are local to the experiment folder:

cd spikingjelly_experiments
python ttfs.py -device cpu -T 2 -epochs 1 -data-dir ./data -out-dir ./logs/ttfs_debug

Other useful entry points include:

python rate.py -device cpu -T 10 -epochs 1 -data-dir ./data -out-dir ./logs/rate_debug
python conv_fashion_mnist.py -device cpu -T 2 -epochs 1 -data-dir ./data -out-dir ./logs/fashion_debug
python inference.py -device cpu -T 2 -data-dir ./data -checkpoint ./logs/example/checkpoint_max.pth
python ann2snn.py -device cpu -data-dir ./data -checkpoint ./SJ-mnist-cnn_model-sample.pth

Datasets are downloaded through torchvision.datasets when download=True. Datasets, logs, checkpoints, TensorBoard files, and generated model weights are ignored by git and should not be committed.

Figures and Data

  • figures/ stores paper figures and generated plots.
  • data/ stores small analytical-model inputs that are intended to be kept in the repository.
  • Large experiment artifacts, checkpoints, and downloaded datasets should be published separately as release assets if they are needed for reproducibility.

Citation

If you use this code, please cite the associated paper:

@article{yu2026rethinking,
  title = {Rethinking the Energy Efficiency of SNNs and ANNs: A Perspective from Neural Network Design},
  author = {Yu, Miao and Xiang, Tingting and Carlson, Trevor E.},
  journal = {ACM Transactions on Architecture and Code Optimization},
  year = {2026}
}

License

This project is released under the MIT License. See LICENSE.

About

An analytical model for estimating and comparing ANN/SNN energy consumption and latency

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages