snnTorch is a Python package for performing gradient-based learning with spiking neural networks. Rather than reinventing the wheel, it sits on top of PyTorch and takes advantage of its GPU accelerated tensor computation. Pre-designed spiking neuron models are seamlessly integrated within the PyTorch framework and can be treated as recurrent activation units.
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.
The following packages need to be installed to use snnTorch:
- torch >= 1.2.0
- numpy >= 1.17
Run the following to install:
pip install snntorch ``
To install snnTorch from source instead:
`` git clone https://github.com/jeshraghian/snnTorch
python setup.py install ``
API & Examples
A complete API is available here. Examples, tutorials and Colab notebooks are provided.