Technical report: supervised training of convolutional spiking neural networks with PyTorch

Romain Zimmer, Thomas Pellegrini, Srisht Fateh Singh, Timothée MasquelierarXiv 2019

Abstract

Recently, it has been shown that spiking neural networks (SNNs) can be trained efficiently, in a supervised manner, using backpropagation through time. Indeed, the most commonly used spiking neuron model, the leaky integrate-and-fire neuron, obeys a differential equation which can be approximated using discrete time steps, leading to a recurrent relation for the potential. The firing threshold causes optimization issues, but they can be overcome using a surrogate gradient. Here, we extend previous approaches in two ways. Firstly, we show that the approach can be used to train convolutional layers. Convolutions can be done in space, time (which simulates conduction delays), or both. Secondly, we include fast horizontal connections à la Denève: when a neuron N fires, we subtract to the potentials of all the neurons with the same receptive the dot product between their weight vectors and the one of neuron N. As Denève et al. showed, this is useful to represent a dynamic multidimensional analog signal in a population of spiking neurons. Here we demonstrate that, in addition, such connections also allow implementing a multidimensional send-on-delta coding scheme. We validate our approach on one speech classification benchmarks: the Google speech command dataset. We managed to reach nearly state-of-the-art accuracy (94%) while maintaining low firing rates (about 5Hz). Our code is based on PyTorch and is available in open source at http://github.com/romainzimmer/s2net

Introduction

Traditional Artificial Neural Networks (ANNs) are computationally expensive and power-hungry, largely because they rely on continuous-valued activations that must be processed at every layer. In contrast, biological brains use discrete "spikes" to transmit information, firing only when necessary. Spiking Neural Networks (SNNs) aim to mimic this efficiency but face a major hurdle: the firing threshold is a non-differentiable step function. This makes standard gradient-based optimization like backpropagation impossible because the gradient is zero everywhere except at the threshold, where it is undefined.

This report presents a practical framework for training Convolutional Spiking Neural Networks (CSNNs) in PyTorch using backpropagation through time and surrogate gradients. The approach bridges the gap between high-performance deep learning and energy-efficient neuromorphic computing.

Methodology

The researchers tackle optimization and architectural challenges using three key components:

  1. Surrogate Gradients: To make the network trainable, the non-differentiable firing threshold is replaced with a "surrogate" during the backward pass. Specifically, the derivative of a sigmoid function approximates the gradient of the Heaviside step function, allowing PyTorch to update weights via Backpropagation Through Time (BPTT).
  2. Convolutional Spiking Layers: The approach extends to convolutional layers that operate across space, time, or both. Convolution in the time domain naturally simulates conduction delays found in biological neural pathways.
  3. Lateral Connections & Send-on-Delta Coding: The authors implement fast horizontal connections inspired by the work of Sophie Denève. When a neuron fires, it subtracts a portion of its potential from its neighbors. This creates a "multi-dimensional send-on-delta" scheme: the population only spikes when the input signal deviates significantly from the network's current internal representation.
Illustration of the send-on-delta coding scheme, where spikes are generated only when the signal x(t) crosses predefined threshold levels (+/- Delta).

Results and Discussion

The model was evaluated on the Google Speech Commands dataset (V1), discriminating between 12 classes of voice commands. Raw audio was converted into Log Mel filterbank coefficients, resulting in a 3-channel input representing frequency over time.

  • Accuracy: The CSNN reached 94% accuracy on the speech command task, nearing the 96-97% typically achieved by standard non-spiking deep learning models.
  • Efficiency: The network achieved this accuracy with a mean firing rate of ~5Hz. In a hardware implementation (like a neuromorphic chip), this would translate to massive power savings compared to traditional GPUs.
  • Sparsity as a Feature: By using a specific regularization term (penalizing the square of the number of spikes), the authors ensure the network remains "quiet," leading to activity levels orders of magnitude lower than standard ANNs.

Conclusion

While PyTorch is excellent for research, it isn't natively optimized for the sparse, event-driven nature of SNNs, meaning theoretical power savings aren't yet fully realized on standard hardware. However, this work demonstrates that CSNNs can achieve high performance with extremely low activity. Future work will involve testing the model on "event-based" data, such as outputs from Dynamic Vision Sensors (DVS cameras), which are naturally suited for spiking architectures.

Summary updated

Abstract

Recently, it has been shown that spiking neural networks (SNNs) can be trained efficiently, in a supervised manner, using backpropagation through time. Indeed, the most commonly used spiking neuron model, the leaky integrate-and-fire neuron, obeys a differential equation which can be approximated using discrete time steps, leading to a recurrent relation for the potential. The firing threshold causes optimization issues, but they can be overcome using a surrogate gradient. Here, we extend previous approaches in two ways. Firstly, we show that the approach can be used to train convolutional layers. Convolutions can be done in space, time (which simulates conduction delays), or both. Secondly, we include fast horizontal connections \`a la Den\`eve: when a neuron N fires, we subtract to the potentials of all the neurons with the same receptive the dot product between their weight vectors and the one of neuron N. As Den\`eve et al. showed, this is useful to represent a dynamic multidimensional analog signal in a population of spiking neurons. Here we demonstrate that, in addition, such connections also allow implementing a multidimensional send-on-delta coding scheme. We validate our approach on one speech classification benchmarks: the Google speech command dataset. We managed to reach nearly state-of-the-art accuracy (94%) while maintaining low firing rates (about 5Hz). Our code is based on PyTorch and is available in open source at http://github.com/romainzimmer/s2net
BibTeX
@misc{zimmer2019technical,
  author = {Romain Zimmer and Thomas Pellegrini and Srisht Fateh Singh and Timothée Masquelier},
  title = {{Technical report: supervised training of convolutional spiking neural networks with PyTorch}},
  year = {2019},
  eprint = {1911.10124},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1911.10124},
}
Figure