Skip to main content

Deep learning with spiking neural networks.

Project description

Introduction

https://img.shields.io/pypi/v/snntorch.svg https://github.com/jeshraghian/snntorch/actions/workflows/build.yml/badge.svg Documentation Status https://github.com/jeshraghian/snntorch/blob/master/docs/_static/img/snntorch_alpha_scaled.png?raw=true

The brain is the perfect place to look for inspiration to develop more efficient neural networks. One of the main differences with modern deep learning is that the brain encodes information in spikes rather than continuous activations. snnTorch is a Python package for performing gradient-based learning with spiking neural networks. It extends the capabilities of PyTorch, taking advantage of its GPU accelerated tensor computation and applying it to networks of spiking neurons. Pre-designed spiking neuron models are seamlessly integrated within the PyTorch framework and can be treated as recurrent activation units.

https://github.com/jeshraghian/snntorch/blob/master/docs/_static/img/spike_excite_alpha_ps2.gif?raw=true

snnTorch Structure

snnTorch contains the following components:

Component

Description

snntorch

a spiking neuron library like torch.nn, deeply integrated with autograd

snntorch.backprop

variations of backpropagation commonly used with SNNs

snntorch.functional

common arithmetic operations on spikes, e.g., loss, regularization etc.

snntorch.spikegen

a library for spike generation and data conversion

snntorch.spikeplot

visualization tools for spike-based data using matplotlib and celluloid

snntorch.spikevision

contains popular neuromorphic datasets

snntorch.surrogate

optional surrogate gradient functions

snntorch.utils

dataset utility functions

snnTorch is designed to be intuitively used with PyTorch, as though each spiking neuron were simply another activation in a sequence of layers. It is therefore agnostic to fully-connected layers, convolutional layers, residual connections, etc.

At present, the neuron models are represented by recursive functions which removes the need to store membrane potential traces for all neurons in a system in order to calculate the gradient. The lean requirements of snnTorch enable small and large networks to be viably trained on CPU, where needed. Provided that the network models and tensors are loaded onto CUDA, snnTorch takes advantage of GPU acceleration in the same way as PyTorch.

Citation

If you find snnTorch useful in your work, please consider citing the following source:

Jason K. Eshraghian, Max Ward, Emre Neftci, Xinxin Wang, Gregor Lenz, Girish Dwivedi, Mohammed Bennamoun, Doo Seok Jeong, and Wei D. Lu “Training Spiking Neural Networks Using Lessons From Deep Learning”. arXiv preprint arXiv:2109.12894, September 2021.

@article{eshraghian2021training,
title={Training spiking neural networks using lessons from deep learning},
author={Eshraghian, Jason K and Ward, Max and Neftci, Emre and Wang, Xinxin
and Lenz, Gregor and Dwivedi, Girish and Bennamoun, Mohammed and Jeong, Doo Seok
and Lu, Wei D},
journal={arXiv preprint arXiv:1906.09395},
year={2021}
}

Requirements

The following packages need to be installed to use snnTorch:

  • torch >= 1.2.0

  • numpy >= 1.17

  • pandas

  • matplotlib

  • math

They are automatically installed if snnTorch is installed using the pip command. Ensure the correct versions of torch and torchvision are installed for your system to enable CUDA compatibility.

Installation

Run the following to install:

$ python
$ pip install snntorch

To install snnTorch from source instead:

$ git clone https://github.com/jeshraghian/snnTorch
$ cd snnTorch
$ python setup.py install

API & Examples

A complete API is available here. Examples, tutorials and Colab notebooks are provided.

Getting Started

Here are a few ways you can get started with snnTorch:

If you wish to learn all the fundamentals of training spiking neural networks, from neuron models, to the neural code, up to backpropagation, the snnTorch tutorial series is a great place to begin. It consists of interactive notebooks with complete explanations that can get you up to speed.

Tutorial

Title

Colab Link

Tutorial 1

Spike Encoding with snnTorch

Open In Colab

Tutorial 2

The Leaky Integrate and Fire Neuron

Open In Colab

Tutorial 3

A Feedforward Spiking Neural Network

Open In Colab

Tutorial 4

2nd Order Spiking Neuron Models (Optional)

Open In Colab

Tutorial 5

Training Spiking Neural Networks with snnTorch

Open In Colab

Tutorial 6

Surrogate Gradient Descent in a Convolutional SNN

Open In Colab

Tutorial 7

Neuromorphic Datasets with Tonic + snnTorch

Open In Colab

Contributing

If you’re ready to contribute to snnTorch, instructions to do so can be found here.

Acknowledgments

snnTorch was initially developed by Jason K. Eshraghian in the Lu Group (University of Michigan).

Additional contributions were made by Xinxin Wang, Vincent Sun, and Emre Neftci.

Several features in snnTorch were inspired by the work of Friedemann Zenke, Emre Neftci, Doo Seok Jeong, Sumit Bam Shrestha and Garrick Orchard.

History

0.1.2 (2021-02-11)

  • Alpha-1 release.

0.0.1 (2021-01-20)

  • First release on PyPI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

snntorch-0.4.8.tar.gz (23.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

snntorch-0.4.8-py2.py3-none-any.whl (61.2 kB view details)

Uploaded Python 2Python 3

File details

Details for the file snntorch-0.4.8.tar.gz.

File metadata

  • Download URL: snntorch-0.4.8.tar.gz
  • Upload date:
  • Size: 23.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for snntorch-0.4.8.tar.gz
Algorithm Hash digest
SHA256 9ed02d800e540b507f21f9211ebdbfe0a585b6bfe20abb38fc8f21d8b2a2bd06
MD5 d547fbb571f4ae04b934d622f3a14faa
BLAKE2b-256 2827630124e3cd635be88bbe58a9c12cef0cb8f46390e4e0cc4bcb4b73274823

See more details on using hashes here.

File details

Details for the file snntorch-0.4.8-py2.py3-none-any.whl.

File metadata

  • Download URL: snntorch-0.4.8-py2.py3-none-any.whl
  • Upload date:
  • Size: 61.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for snntorch-0.4.8-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 e80bf3a6ed32815786ef77ce3f82f9f99699d6e296a31ff6bd0d768179fa0da7
MD5 12bc5a0a0388cdaf448858ff95c5e689
BLAKE2b-256 4049e4840322c1e89f0d5662f7f342f23728dce54d533258eebea9619fc130b6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page