Abstract
Spiking Neural Networks (SNNs) represent a bio-inspired, energy-efficient paradigm for artificial intelligence, utilizing sparse binary spikes for information processing. Recent advancements have integrated SNNs with Transformer architectures, yet these "Spiking Transformers" predominantly focus on spatial attention, overlooking the critical temporal dimension inherent to spiking data. We present STAtten, a novel spatial-temporal attention mechanism that captures both spatial and temporal dependencies through a block-wise computation strategy. STAtten achieves state-of-the-art accuracy on static and neuromorphic benchmarks while maintaining the computational efficiency of spatial-only models.
Introduction: The Temporal Blind Spot in Spiking Transformers
Spiking Neural Networks (SNNs) are often hailed as the "green" alternative to traditional Artificial Neural Networks (ANNs) due to their event-driven nature and sparse computation. By mimicking the human brain's use of discrete spikes, SNNs can significantly reduce energy consumption on specialized neuromorphic hardware. The recent fusion of SNNs with Transformer architectures has led to impressive performance gains. However, a fundamental limitation persists: most existing Spiking Transformers utilize spatial-only attention, treating the temporal sequence of spikes as independent snapshots or failing to model the intricate relationships between spikes across different timesteps.
Ignoring the temporal dimension leads to suboptimal feature representation. While "full" temporal attention could theoretically solve this, it introduces $O(T^2)$ computational complexity and often suffers from the "dead neuron" problem, where spikes from distant timesteps are too dissimilar to provide meaningful correlations.
Methods: STAtten and Block-wise Computation
To address these challenges, we introduce STAtten (Spatial-Temporal Attention), a plug-and-play module designed to replace standard Spiking Self-Attention (SSA). The core of STAtten is a block-wise computation strategy that balances temporal modeling with computational efficiency.
- Temporal Partitioning: The temporal dimension $T$ is divided into small, manageable blocks (e.g., $B=2$ or $4$).
- Local Correlation: Attention is computed within these local blocks, allowing the model to capture how features evolve over short windows—crucial for understanding motion or transient spike patterns—without the memory overhead of global temporal attention.
- Binary-Friendly Design: To maintain the advantages of SNNs, STAtten avoids the Softmax function. Instead, it utilizes linear projections and Leaky Integrate-and-Fire (LIF) neurons to ensure all communication remains spike-based and binary.
- Complexity Matching: By reordering matrix multiplications to $Q(K^\top V)$, STAtten maintains a computational complexity of $O(TND^2)$, identical to existing spatial-only spiking transformers. This ensures that the added temporal awareness does not come at the cost of increased latency or power.
Key Insights: Entropy and Neuron Vitality
A critical finding of this work is the relationship between attention type, information structure, and model performance. By analyzing the Shannon entropy of spike patterns, we observed that spatial-temporal attention leads to lower entropy compared to spatial-only or temporal-only models. Lower entropy indicates more structured, "focused" spike patterns, which correlate directly with higher classification accuracy.
Furthermore, the block-wise approach mitigates the "dead neuron" issue. In full temporal attention, trying to correlate spikes across long intervals often results in near-zero activation. By restricting attention to local temporal blocks, STAtten keeps neurons "alive," ensuring they fire meaningful patterns that contribute to the final prediction.
Experimental Results
STAtten was evaluated across a wide array of datasets, including static images (CIFAR, ImageNet), sequential data, and native neuromorphic (event-based) datasets.
- Neuromorphic Excellence: On the CIFAR10-DVS dataset, STAtten (integrated into a QKFormer backbone) achieved a new state-of-the-art accuracy of 83.90%.
- Sequential Data Gains: The benefits of temporal modeling were most evident in sequential tasks. On sequential CIFAR-100, STAtten boosted the Spike-driven Transformer's accuracy by 3.22% (from 61.08% to 64.30%).
- Large-Scale Performance: On ImageNet-1K, the model reached 78.11% top-1 accuracy, outperforming spatial-only baselines while maintaining extreme energy efficiency.
- Energy Efficiency: Inference on ImageNet-1K consumes approximately 12.36 mJ, a fraction of the 254.84 mJ required by a standard non-spiking Vision Transformer (ViT-B/16).
Conclusion and Future Directions
STAtten successfully bridges the gap in Spiking Transformers by introducing efficient spatial-temporal modeling. While the module is "plug-and-play" for various backbones, its full potential on silicon is currently limited by existing neuromorphic hardware. Most current chips process timesteps sequentially, whereas STAtten's block-wise approach benefits from parallel temporal processing. Future research will focus on co-designing neuromorphic architectures and "layer-by-layer" processing strategies to fully realize the hardware benefits of spatial-temporal spiking attention.
Summary updated