Directly Training Temporal Spiking Neural Network with Sparse Surrogate Gradient

Yang Li, Feifei Zhao, Dongcheng Zhao, Yi Zeng

TL;DR

This paper introduces two novel techniques to improve the direct training of Spiking Neural Networks (SNNs): Masked Surrogate Gradients (MSG) and Temporally Weighted Output (TWO). By re-introducing sparsity into the gradient calculation and adaptively weighting the importance of different timesteps, the authors achieve state-of-the-art performance across several major static and neuromorphic datasets.

What Problem Does This Paper Address?

Spiking Neural Networks (SNNs) are the "third generation" of neural networks, prized for their biological plausibility and extreme energy efficiency on neuromorphic hardware. Unlike standard Artificial Neural Networks (ANNs), SNNs communicate via discrete, binary "spikes."

However, this binary nature makes them notoriously difficult to train. The mathematical function for a spike is non-differentiable (a Dirac delta function), which breaks the standard backpropagation algorithm used in deep learning. To get around this, researchers use Surrogate Gradients (SG)—smooth functions that approximate the spike's gradient during training.

The authors identify a "Dilemma of SG":

  1. Wide SGs cover a large range of membrane potentials but introduce "gradient mismatch," where parameters are updated based on noisy, inaccurate information.
  2. Narrow SGs are more accurate but lead to "gradient vanishing," where too few neurons provide useful gradients for learning.

Furthermore, most SNNs treat every timestep's output as equally important, ignoring the fact that the network's confidence and accuracy often evolve over time.

Figure 1: Extreme surrogate gradients can result in gradient mismatch or vanishing issues. For inputs sharing a consistent membrane potential distribution, the gradient’s statistical histogram reflects two polar outcomes when using either excessively wide or narrow widths: a significant portion of parameters undergo updates, or conversely, only a minimal set of parameters are updated.

Methods

The researchers propose a two-pronged optimization strategy:

1. Masked Surrogate Gradient (MSG)

Instead of trying to find the "perfect" smooth surrogate function, MSG embraces the inherent sparsity of SNNs. During backpropagation, the algorithm generates a random binary mask (based on a Bernoulli distribution with probability $p$). This mask is applied to the surrogate gradients, meaning only a subset of parameters are updated at each iteration.

  • Why it works: Mathematically, this increases the variance of the gradient updates. This acts as a powerful regularizer, helping the network "jump" out of local minima and saddle points in the loss landscape that might otherwise trap a standard SG-trained network.

2. Temporally Weighted Output (TWO)

SNNs process data over multiple timesteps. Standard methods usually average the output over time. TWO instead uses a Temporal Importance Factor (TIF).

  • How it works: The network tracks the historical accuracy of each individual timestep during training. It then assigns higher weights to timesteps that are more likely to be correct (typically later timesteps). This adaptive weighting allows for more precise decoding of the network's "spiking" intent.

Datasets

The authors evaluated their methods on a diverse set of benchmarks:

  • Static Datasets: CIFAR-10, CIFAR-100, and ImageNet. These are standard computer vision benchmarks where images are converted into spike trains.
  • Neuromorphic Datasets: DVS-CIFAR10 and N-CALTECH101. These datasets consist of event-based data captured by bio-inspired cameras, representing a more "native" use case for SNNs.

Key Insights and Ideas

  • Sparsity is a Feature, Not a Bug: While surrogate gradients were designed to "smooth out" SNNs to make them look more like ANNs, the authors argue that losing gradient sparsity actually hurts generalization. MSG restores this sparsity.
  • The "Sweet Spot" for Masking: Through extensive testing, the authors found that a mask probability ($p$) between 0.4 and 0.6 is optimal. If $p$ is too high, the gradient vanishes; if it's too low, the network suffers from the original SG mismatch issues.
  • Temporal Evolution of Accuracy: The TWO method reveals that SNNs aren't just "averaging" information; their internal state becomes more refined over time. By acknowledging that later timesteps are often more reliable, the network achieves higher accuracy with fewer total timesteps.
  • Efficiency: Crucially, adding the masking operation and temporal weighting adds negligible computational overhead to the training process, as shown in their training time analysis.

Key Results

The combination of MSG and TWO consistently outperformed previous state-of-the-art (SOTA) direct training methods:

  • CIFAR-10: Achieved 95.65% top-1 accuracy, surpassing previous direct training methods like TET and Dspike.
  • DVS-CIFAR10: Reached 83.97% accuracy, a significant improvement for neuromorphic data.
  • CIFAR-100: Achieved 77.48% accuracy, showing strong performance even on more complex classification tasks.
  • ImageNet: On the massive ImageNet dataset, they achieved 67.46% accuracy in just 4 timesteps, demonstrating that the method scales to large-scale problems.

Limitations and Future Work

While the results are impressive, the authors noted that on ImageNet, their performance was slightly lower than the TET (Temporal Efficient Training) method. They attribute this to the fact that ImageNet inputs are static across all timesteps, which might favor TET's specific loss function.

Future work could explore applying MSG to online learning scenarios. Because MSG reduces the number of active gradient updates, it could significantly lower the computational load for edge devices that need to learn in real-time. Additionally, investigating how these methods interact with different neuron models beyond the standard Leaky Integrate-and-Fire (LIF) model remains an open question.

Summary updated

BibTeX
@article{li2024directly,
  author = {Yang Li and Feifei Zhao and Dongcheng Zhao and Yi Zeng},
  title = {{Directly Training Temporal Spiking Neural Network with Sparse Surrogate Gradient}},
  journal = {Neural Networks},
  year = {2024},
  doi = {10.1016/j.neunet.2024.106499},
}
Figure