Directly training temporal Spiking Neural Network with sparse surrogate gradient

Yang Li, Feifei Zhao, Dongcheng Zhao, Yi Zeng

Introduction

Spiking Neural Networks (SNNs) represent the "third generation" of neural networks, offering biological plausibility and high energy efficiency on neuromorphic hardware. Unlike traditional Artificial Neural Networks (ANNs), SNNs communicate via discrete spikes. However, the Heaviside step function used to generate these spikes is non-differentiable, making direct training via backpropagation challenging.

The Dilemma of Surrogate Gradients

To overcome the non-differentiability of the spiking function, researchers typically employ Surrogate Gradients (SG). These functions replace the zero-gradient of the step function with a smooth, differentiable approximation during the backward pass. However, this approach introduces a fundamental trade-off known as the "Dilemma of SG."

The Dilemma of Surrogate Gradients: Wide SGs lead to gradient mismatch, while narrow SGs cause gradient vanishing.

As shown in Figure 1, the dilemma manifests in two ways:

  1. Wide SGs: By covering a larger range of membrane potentials, they ensure gradients flow but create a "gradient mismatch" where the update does not accurately reflect the actual spiking threshold behavior.
  2. Narrow SGs: These more closely approximate the step function but often lead to "gradient vanishing," where the signal diminishes before reaching the earlier layers of the network.

Furthermore, standard SGs eliminate the natural sparsity of the gradient, which can trap models in local minima and ignore the temporal nuances of spike-based information.

Proposed Methodology

The authors introduce two primary techniques to address these issues: Masked Surrogate Gradients (MSG) and Temporally Weighted Output (TWO).

Masked Surrogate Gradient (MSG)

MSG restores gradient sparsity by applying a random binary mask generated from a Bernoulli distribution during backpropagation. Instead of calculating a smooth surrogate gradient for every parameter, only a subset is updated. This re-introduction of sparsity increases the variance of gradient updates, acting as a powerful regularizer that helps the network escape saddle points and find superior local minima without increasing the firing rate or training time.

Temporally Weighted Output (TWO)

Standard SNN training often treats all timesteps equally by averaging synaptic currents. However, the authors observed that later timesteps typically carry more informative signals for classification. TWO adaptively assigns a "Temporal Importance Factor" to each timestep based on historical training statistics. These weights are updated via a low-pass filter, allowing the network to prioritize the most relevant temporal moments for decision-making. Analysis shows that the importance of the first few timesteps drops significantly over training epochs, while later timesteps become the primary drivers of accuracy.

Experimental Results

The proposed methods were evaluated on both static (CIFAR-10/100, ImageNet) and neuromorphic (DVS-CIFAR10, NCALTECH101) datasets.

  • CIFAR-10/100: The model achieved state-of-the-art (SOTA) results, reaching 95.65% on CIFAR-10 with only 4 timesteps and 77.48% on CIFAR-100, significantly outperforming previous direct training methods like Dspike.
  • Neuromorphic Datasets: On DVS-CIFAR10, the method reached 83.97% accuracy, surpassing the previous best (TET) by 0.8%.
  • Ablation Studies: Combining MSG and TWO consistently provided a 1-7% accuracy boost over vanilla surrogate gradient training, demonstrating the synergy between gradient regularization and temporal weighting.

Conclusion

By embracing the inherent sparsity of spiking neurons rather than smoothing it away, the Masked Surrogate Gradient (MSG) method provides a robust regularization mechanism. When paired with Temporally Weighted Output (TWO), SNNs can achieve high performance with extremely low latency. Future work may focus on optimizing the mask probability for deeper architectures and implementing these sparse updates directly on neuromorphic hardware for further efficiency gains.

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