Spiking Transformer with Spatial-Temporal Attention

TL;DR

Proposed STAtten enhances Spike Transformers by integrating block-wise spatial-temporal attention, achieving significant accuracy gains on CIFAR and ImageNet datasets.

cs.NE 🔴 Advanced 2024-09-30 48 citations 57 views
Donghyun Lee Yuhang Li Youngeun Kim Shiting Xiao Priyadarshini Panda
Neural Networks Transformers Spiking Neural Networks Spatial-Temporal Attention Energy Efficiency

Key Findings

Methodology

STAtten employs block-wise local temporal attention with binary Q, K, V, avoiding Softmax to maintain low complexity O(T N D^2). It partitions temporal sequences into manageable chunks, capturing local temporal dependencies. Information entropy analysis confirms the importance of joint spatial-temporal features. The design integrates seamlessly into existing spike-based transformers, enhancing their representational capacity while preserving efficiency.

Key Results

  • On CIFAR10/100, ImageNet, CIFAR10-DVS, and N-Caltech101, STAtten improves accuracy significantly. For example, in QKFormer, CIFAR10 accuracy rises from 94.96% to 95.35%, CIFAR100 from 79.79% to 80.20%. In sequential CIFAR tasks, performance increases over 3%.
  • Energy consumption remains comparable to spatial-only models due to the non-Softmax design, enabling efficient long-range temporal modeling.
  • Ablation studies show block size and local window choices critically influence performance, validating the local temporal modeling approach.

Significance

This work addresses the core limitation of existing spike transformers by effectively modeling temporal dependencies, leading to improved feature representation and long-range dependency capture. It advances the state-of-the-art in energy-efficient neuromorphic vision processing, with broad implications for real-world applications such as video analysis and robotic perception, where temporal dynamics are crucial.

Technical Contribution

Introducing a block-wise spatial-temporal attention mechanism compatible with existing spike transformers, maintaining O(T N D^2) complexity. The approach leverages binary Q, K, V for low-cost computation, validated by entropy analysis. It balances local temporal modeling with computational efficiency, opening new avenues for deep, dynamic feature extraction in neuromorphic systems.

Novelty

First to implement block-wise local temporal attention in spike-based transformers, capturing local temporal correlations without increasing complexity. Unlike prior spatial-only methods, it models temporal dependencies explicitly, validated by entropy and accuracy improvements, representing a significant step forward in neuromorphic sequence modeling.

Limitations

  • The block partitioning strategy may limit modeling of very long-range dependencies beyond local windows. Future work could explore adaptive block sizes or hierarchical approaches.
  • Model robustness under extreme hardware constraints or very sparse spike activity remains untested, requiring hardware-aware optimizations.
  • While complexity remains low, scaling to ultra-long sequences or high-dimensional data may still pose computational challenges, necessitating further algorithmic innovations.

AI Executive Summary

Neuromorphic computing and neural networks have evolved significantly, with transformers revolutionizing sequence modeling. However, traditional spike-based models primarily focus on spatial relationships, neglecting the inherent temporal dynamics of spike signals. This oversight limits their ability to fully exploit the rich information embedded in temporal patterns, especially for tasks like video recognition and dynamic scene understanding.

To overcome this, our research introduces STAtten, a novel block-wise spatial-temporal attention mechanism tailored for spike transformers. By partitioning temporal sequences into local chunks, STAtten captures local temporal dependencies efficiently, without incurring the quadratic complexity associated with full temporal correlation. The key innovation lies in using binary Q, K, V representations, which eliminate the need for Softmax and significantly reduce energy consumption. We validate the effectiveness of this approach through extensive experiments on static datasets like CIFAR and ImageNet, as well as dynamic neuromorphic datasets such as CIFAR10-DVS and N-Caltech101.

Results demonstrate that integrating STAtten into existing architectures yields consistent accuracy improvements, with CIFAR10 accuracy reaching 95.35% and CIFAR100 80.20% in QKFormer. The model also exhibits superior long-range dependency modeling, confirmed by entropy analysis and ablation studies. Importantly, the approach maintains the low-energy profile characteristic of spike-based systems, making it suitable for edge devices.

This work marks a significant step toward more capable and efficient neuromorphic vision systems. Future directions include multi-scale temporal modeling, hardware-aware optimization, and extending to multi-modal tasks. Overall, STAtten opens new horizons for dynamic, energy-efficient sequence processing in spike neural networks, bridging the gap between biological plausibility and practical performance.

Deep Analysis

Background

The evolution of neural networks from CNNs to transformers has dramatically improved sequence modeling capabilities, especially in vision and speech tasks. Spiking Neural Networks (SNNs) mimic biological neurons, offering low power consumption and event-driven processing. Recent efforts combine transformers with SNNs, such as Spikformer and Spike-driven Transformer, to leverage self-attention's ability to model long-range dependencies. However, these models predominantly focus on spatial attention, neglecting the temporal dynamics intrinsic to spike signals. This oversight limits their ability to fully utilize the temporal information, which is vital for dynamic scene understanding and neuromorphic applications. Addressing this gap requires novel mechanisms that efficiently incorporate temporal dependencies without compromising energy efficiency.

Core Problem

Current spike-based transformers mainly rely on spatial attention, which fails to capture the temporal evolution of spike patterns. This results in suboptimal feature representations, especially in sequential tasks like video recognition. Fully correlating temporal information across all time steps introduces high computational and memory costs, making it impractical for neuromorphic hardware. Therefore, designing an efficient, scalable method to model local temporal dependencies while preserving low complexity remains a key challenge. Additionally, existing approaches lack rigorous validation of the importance of temporal information, limiting their effectiveness in real-world applications.

Innovation

The core innovation is the development of block-wise spatial-temporal attention (STAtten), which models local temporal dependencies within manageable chunks. This approach reduces memory and computation overhead, enabling long sequence processing. It employs binary Q, K, V representations, eliminating Softmax and maintaining low energy consumption. The method is validated through entropy analysis, confirming the importance of joint spatial-temporal features. Unlike prior models that ignore temporal dynamics or incur high complexity, STAtten balances efficiency and expressive power, providing a scalable solution for dynamic sequence modeling in neuromorphic systems.

Methodology

  • �� Partition the temporal sequence into blocks of size B, reducing memory footprint.
  • �� Use binary Q, K, V for self-attention, avoiding Softmax to lower complexity.
  • �� Compute local spatial-temporal attention within each block, capturing local dependencies.
  • �� Apply entropy analysis to verify the significance of temporal information.
  • �� Integrate residual connections to enhance feature stability.
  • �� Implement the process by reshaping tensors, performing block-wise matrix multiplications, and concatenating features for subsequent layers.

Experiments

Experiments span static datasets (CIFAR10/100, ImageNet) and neuromorphic datasets (CIFAR10-DVS, N-Caltech101). Models are trained from scratch using direct surrogate gradient methods. Hyperparameters include block size B and timestep number T. Performance is evaluated via accuracy, energy consumption, and entropy metrics. Ablation studies analyze the impact of block size and local window choices, confirming the effectiveness of local temporal modeling. Results show consistent improvements over spatial-only attention, validating the approach's scalability and robustness.

Results

Across datasets, models with STAtten outperform baselines. For example, in QKFormer, CIFAR10 accuracy improves from 94.96% to 95.35%, CIFAR100 from 79.79% to 80.20%. On ImageNet, accuracy reaches 78.11% at 224×224 resolution. Entropy measurements show lower entropy (4.85) correlates with higher accuracy (79.9%), indicating better feature structure. The method maintains low energy consumption due to binary operations, demonstrating practical viability for neuromorphic hardware.

Plain Language Accessible to non-experts

Imagine a busy kitchen where chefs prepare dishes. Traditional methods only focus on what ingredients are on the counter (spatial info), ignoring how ingredients change over time, like how a sauce thickens or a dish cools down. Our new approach is like giving chefs a smart assistant that watches both the ingredients and their changes over time, helping them cook better and faster. This assistant looks at small groups of steps, understanding how things evolve locally, so the kitchen runs smoothly without extra energy. It’s like having a super-smart, energy-efficient chef helper that makes the whole cooking process smarter and more efficient, especially when dealing with complex recipes that need timing and coordination.

ELI14 Explained like you're 14

Think about playing a video game. You see what’s happening on the screen, but you also need to remember what just happened a few seconds ago to make the right move. If you only focus on what’s immediately in front of you, you might miss important clues from earlier scenes. Now, imagine if you had a special camera that not only shows you the current scene but also remembers the recent past in a smart way, helping you understand the story better. That’s what this new method does for computers: it helps them see both the current picture and how things are changing over time, all while using less energy. It’s like giving the computer a superpower to understand videos or dynamic scenes more like humans do, making it smarter and more efficient at recognizing moving objects or actions.

Glossary

空间-时间注意力 (Spatial-Temporal Attention)

一种结合空间关系和时间动态的注意力机制,用于增强模型对序列数据的理解能力。技术上通过块式局部时间建模实现低复杂度的联合特征捕获。

本文提出的STAtten核心机制。

二值Q、K、V (Binary Q, K, V)

在脉冲神经网络中,Q、K、V采用二值表示,简化计算,避免Softmax,降低能耗。

实现低复杂度自注意力的关键技术。

信息熵 (Information Entropy)

衡量注意力分布的集中程度,低熵表示信息集中,模型更具判别性。

验证空间-时间联合注意力效果的重要指标。

Open Questions Unanswered questions from this research

  • 1 如何进一步优化块大小和局部时间窗口,以适应极长序列和高动态场景,仍需深入研究。
  • 2 在硬件限制极端条件下,模型的鲁棒性和能效表现尚未充分验证,未来需结合硬件特性优化。

Abstract

Spike-based Transformer presents a compelling and energy-efficient alternative to traditional Artificial Neural Network (ANN)-based Transformers, achieving impressive results through sparse binary computations. However, existing spike-based transformers predominantly focus on spatial attention while neglecting crucial temporal dependencies inherent in spike-based processing, leading to suboptimal feature representation and limited performance. To address this limitation, we propose Spiking Transformer with Spatial-Temporal Attention (STAtten), a simple and straightforward architecture that efficiently integrates both spatial and temporal information in the self-attention mechanism. STAtten introduces a block-wise computation strategy that processes information in spatial-temporal chunks, enabling comprehensive feature capture while maintaining the same computational complexity as previous spatial-only approaches. Our method can be seamlessly integrated into existing spike-based transformers without architectural overhaul. Extensive experiments demonstrate that STAtten significantly improves the performance of existing spike-based transformers across both static and neuromorphic datasets, including CIFAR10/100, ImageNet, CIFAR10-DVS, and N-Caltech101. The code is available at https://github.com/Intelligent-Computing-Lab-Yale/STAtten

cs.NE

References (20)

QKFormer: Hierarchical Spiking Transformer using Q-K Attention

Chenlin Zhou, Han Zhang, Zhaokun Zhou et al.

2024 119 citations ⭐ Influential View Analysis →

Spike-driven Transformer V2: Meta Spiking Neural Network Architecture Inspiring the Design of Next-generation Neuromorphic Chips

Man Yao, Jiakui Hu, Tianxiang Hu et al.

2024 207 citations ⭐ Influential View Analysis →

Spike-driven Transformer

Man Yao, Jiakui Hu, Zhaokun Zhou et al.

2023 354 citations ⭐ Influential View Analysis →

Spikformer: When Spiking Neural Network Meets Transformer

Zhaokun Zhou, Yuesheng Zhu, Chao He et al.

2022 568 citations ⭐ Influential View Analysis →

Advancing Spiking Neural Networks Toward Deep Residual Learning

Yifan Hu, Lei Deng, Yujie Wu et al.

2021 240 citations ⭐ Influential View Analysis →

Post-Training Quantization for Vision Transformer

Zhenhua Liu, Yunhe Wang, Kai Han et al.

2021 523 citations ⭐ Influential View Analysis →

Spike-Triggered Non-Autoregressive Transformer for End-to-End Speech Recognition

Zhengkun Tian, Jiangyan Yi, J. Tao et al.

2020 56 citations View Analysis →

Incorporating Learnable Membrane Time Constant to Enhance Learning of Spiking Neural Networks

W. Fang, Zhaofei Yu, Yan-Qing Chen et al.

2020 809 citations View Analysis →

Attention is All you Need

Ashish Vaswani, Noam Shazeer, Niki Parmar et al.

2017 192915 citations View Analysis →

DIET-SNN: Direct Input Encoding With Leakage and Threshold Optimization in Deep Spiking Neural Networks

Nitin Rathi, K. Roy

2020 166 citations View Analysis →

Going Deeper With Directly-Trained Larger Spiking Neural Networks

Hanle Zheng, Yujie Wu, Lei Deng et al.

2020 767 citations View Analysis →

Training data-efficient image transformers & distillation through attention

Hugo Touvron, M. Cord, Matthijs Douze et al.

2020 9799 citations View Analysis →

Deep Residual Learning in Spiking Neural Networks

W. Fang, Zhaofei Yu, Yan-Qing Chen et al.

2021 835 citations View Analysis →

An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale

Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov et al.

2020 69847 citations View Analysis →

Towards spike-based machine intelligence with neuromorphic computing

K. Roy, Akhilesh R. Jaiswal, P. Panda

2019 2282 citations

Towards artificial general intelligence with hybrid Tianjic chip architecture

Jing Pei, Lei Deng, Sen Song et al.

2019 1128 citations

Spiking-YOLO: Spiking Neural Network for Energy-Efficient Object Detection

Seijoon Kim, Seongsik Park, Byunggook Na et al.

2019 560 citations View Analysis →

Direct Training for Spiking Neural Networks: Faster, Larger, Better

Yujie Wu, Lei Deng, Guoqi Li et al.

2018 816 citations View Analysis →

SLAYER: Spike Layer Error Reassignment in Time

S. Shrestha, G. Orchard

2018 955 citations View Analysis →

Entropy and mutual information in models of deep neural networks

Marylou Gabrié, Andre Manoel, Clément Luneau et al.

2018 208 citations View Analysis →

Cited By (20)

STEG-AIW: Spatio-Temporal Gating and Adaptive-Timestep Inference for Efficient Spiking Neural Networks

2026 ⭐ Influential

Spatial-Augmented Transformer with Adaptive Framing for Event-Based Human Action Recognition

2026 ⭐ Influential

Benchmarking Fairness in Spiking Neural Networks: Data Bias, Spurious Features, and Hardware Effects

2026 ⭐ Influential View Analysis →

SpikePool: Event-driven Spiking Transformer with Pooling Attention

2025 1 citations ⭐ Influential View Analysis →

Efficient Transformer Attention for SNNs via Hadamard Simplification

1 citations

TEFormer: Structured Bidirectional Temporal Enhancement Modeling in Spiking Transformers

2026 1 citations View Analysis →

MI-TRQR: Mutual Information-Based Temporal Redundancy Quantification and Reduction for Energy-Efficient Spiking Neural Networks

2025

SpiLiFormer: Enhancing Spiking Transformers with Lateral Inhibition

2025 8 citations View Analysis →

MK-SGN: A Spiking Graph Convolutional Network with Multimodal Fusion and Knowledge Distillation for Skeleton-based Action Recognition

2024 8 citations View Analysis →

SNN-Driven Multimodal Human Action Recognition via Sparse Spatial-Temporal Data Fusion

2025 5 citations View Analysis →

ASG-TDM: A Graph-Enhanced Transformer With Spiking Preprocessing and a Dendritic Head for Multi-Task Facial Analysis

2026 1 citations

Quantization Meets Spikes: Nearly Lossless Conversion at the First Timestep via Polarity Multi-Spike Mapping

ASecond-Order SpikingSSM for Wearables

2025 1 citations View Analysis →

Temporal Dynamics Enhancer for Directly Trained Spiking Object Detectors

2025 3 citations View Analysis →

MD-SNN: Membrane Potential-aware Distillation on Quantized Spiking Neural Network

Signal-SGN++: Topology-Enhanced Time-Frequency Spiking Graph Network for Skeleton-Based Action Recognition

2025 1 citations View Analysis →

SQKformer: Spiking sparse QKformer with adaptive batch normalization for membrane potential

2026 4 citations

A Four-Stage Structural Evolution Framework for Spiking Neural Networks: A Review and Perspective from Binary ANN to Event-Driven Models

2026 2 citations

Hybrid Convolutional Autoencoder with Spiking Neural Network-Based Compression Approach with Binary Spike Latent for Telemedicine and Archival

2026

Differential attention vision transformer with adaptive spatial feature conditioning for remote sensing scene classification

2026 2 citations