[论文解读] QKFormer: Hierarchical Spiking Transformer using Q-K Attention
QKFormer 引入了一个脉冲形式的 Q-K 注意力,具有线性复杂度,并配备一个 Patch Embedding 的 Deformed Shortcut,使得能够直接训练的分层脉冲 Transformer,在 ImageNet-1k 及其他数据集上超越先前的 SNN 模型。
Spiking Transformers, which integrate Spiking Neural Networks (SNNs) with Transformer architectures, have attracted significant attention due to their potential for energy efficiency and high performance. However, existing models in this domain still suffer from suboptimal performance. We introduce several innovations to improve the performance: i) We propose a novel spike-form Q-K attention mechanism, tailored for SNNs, which efficiently models the importance of token or channel dimensions through binary vectors with linear complexity. ii) We incorporate the hierarchical structure, which significantly benefits the performance of both the brain and artificial neural networks, into spiking transformers to obtain multi-scale spiking representation. iii) We design a versatile and powerful patch embedding module with a deformed shortcut specifically for spiking transformers. Together, we develop QKFormer, a hierarchical spiking transformer based on Q-K attention with direct training. QKFormer shows significantly superior performance over existing state-of-the-art SNN models on various mainstream datasets. Notably, with comparable size to Spikformer (66.34 M, 74.81%), QKFormer (64.96 M) achieves a groundbreaking top-1 accuracy of 85.65% on ImageNet-1k, substantially outperforming Spikformer by 10.84%. To our best knowledge, this is the first time that directly training SNNs have exceeded 85% accuracy on ImageNet-1K. The code and models are publicly available at https://github.com/zhouchenlin2096/QKFormer
研究动机与目标
- 激励在视觉任务中实现能效高、性能强的脉冲神经网络。
- 开发一个可以直接训练的分层脉冲 Transformer(非转换)。
- 提出一个线性复杂度的脉冲形式 Q-K 注意力机制。
- 设计一个带 Deformed Shortcut 的 Patch Embedding 模块,以改善信息流。
- 在 ImageNet-1k 及其他数据集上展示状态-of-the-art 成果。
提出的方法
- 提出使用脉冲形式的 Query (Q) 和 Key (K) 来计算 token 和 channel 重要性,具有线性复杂度的 Q-K 注意力。
- 将 Q-K 注意力分解为 Q-K Token Attention (QKTA) 和 Q-K Channel Attention (QKCA),并结合脉冲形式屏蔽与简单聚合。
- 将 Patch Embedding 模块与 Deformed Shortcut (PEDS) 集成,以在 patch embedding 中实现残差学习。
- 构建一个三阶段、逐步降低 token 数量、增加通道维度的 Hierarchical Spiking Transformer (QKFormer)。
- 直接在脉冲域进行训练,并使用 Spiking MLP (SMLP) 以及最终的 FC 层进行分类。
- 在 ImageNet-1k、CIFAR-10/100、CIFAR10-DVS、以及 DVS128 Gesture 上进行广泛实验,以验证性能和效率。
实验结果
研究问题
- RQ1脉冲形式的 Q-K 注意力是否能在 SNN 中实现线性计算复杂度,同时有效建模 token 与 channel 的重要性?
- RQ2将 Q-K 注意力融入分层脉冲结构,是否在大规模视觉任务上提升现有 SNN Transformer 的性能?
- RQ3带 Deformed Shortcut 的 Patch Embedding 模块(PEDS)是否提升脉冲 Transformer 的信息传输与准确性?
- RQ4直接训练的 SNN 是否能在合理的时间步下达到或超过 ImageNet-1k 的 85% Top-1 准确率?
主要发现
- QKFormer 在 ImageNet-1k 的 Top-1 准确率达到 85.65%,在 4 个时间步和 64.96M 参数规模下(本论文报告中最佳)。
- QKFormer 在相近模型大小下比 Spikformer 高出 10.84 个百分点(85.65% vs 74.81%)。
- 直接训练的 SNN 在本工作中首次超过 85% 的 ImageNet-1k Top-1 准确率。
- Q-K 注意力具有线性时间/空间特性,QKTA 和 QKCA 通过脉冲形式操作实现高效的 token 与 channel 加权。
- PEDS 在 CIFAR100 和 CIFAR10-DVS 上相较基线 Spikformer 提供可观的准确提升(CIFAR100: +2.05%;CIFAR10-DVS: +1.3%)。
- QKFormer 在静态数据集和神经形态数据集上均表现出强劲性能,与二次方注意力的对手相比,具有更好的内存与能量特性。
阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。