Skip to main content
QUICK REVIEW

[论文解读] Spikformer: When Spiking Neural Network Meets Transformer

Zhaokun Zhou, Yuesheng Zhu|arXiv (Cornell University)|Sep 29, 2022
Advanced Memory and Neural ComputingEngineering被引用 103
一句话总结

本文提出 Spiking Self Attention (SSA) 和 Spiking Transformer (Spikformer),直接在尖峰基数据上运作,在 ImageNet 上实现直接训练的 SNN 之间的最新水平,并在神经形态数据集上具有竞争力,同时保持能效。

ABSTRACT

We consider two biologically plausible structures, the Spiking Neural Network (SNN) and the self-attention mechanism. The former offers an energy-efficient and event-driven paradigm for deep learning, while the latter has the ability to capture feature dependencies, enabling Transformer to achieve good performance. It is intuitively promising to explore the marriage between them. In this paper, we consider leveraging both self-attention capability and biological properties of SNNs, and propose a novel Spiking Self Attention (SSA) as well as a powerful framework, named Spiking Transformer (Spikformer). The SSA mechanism in Spikformer models the sparse visual feature by using spike-form Query, Key, and Value without softmax. Since its computation is sparse and avoids multiplication, SSA is efficient and has low computational energy consumption. It is shown that Spikformer with SSA can outperform the state-of-the-art SNNs-like frameworks in image classification on both neuromorphic and static datasets. Spikformer (66.3M parameters) with comparable size to SEW-ResNet-152 (60.2M,69.26%) can achieve 74.81% top1 accuracy on ImageNet using 4 time steps, which is the state-of-the-art in directly trained SNNs models.

研究动机与目标

  • 促使将自注意力与脉冲神经网络(SNNs)相结合,以同时利用能效和全局特征建模。
  • 设计一种与尖峰计算兼容的自注意力变体(SSA),避免乘法和 softmax。
  • 构建由 SSA 构成的 Spiking Transformer (Spikformer),并在静态和神经形态数据集上验证其有效性。
  • 证明直接训练的 Spikformer 在 ImageNet 和神经形态基准上超越既有 SNN 架构,同时具备能效优势。

提出的方法

  • 提出 Spiking Self Attention (SSA),使用尖峰形式的 Query、Key 和 Value,在计算注意力时不使用 softmax。
  • 通过可学习的变换得到 Q、K、V,随后经尖峰神经元层,产生值为 0/1 的序列。
  • 应用缩放因子来稳定点积计算,并通过尖峰运算(逻辑与和加法)执行注意力。
  • 使用 Spiking Patch Splitting (SPS) 模块对补丁进行嵌入,并添加由尖峰基块生成的尖峰形式相对位置嵌入(RPE)。
  • 堆叠 Spikformer 编码器块(SSA + 具有残差的 MLP),并使用全局平均池化和线性头进行分类。
  • 使用批量归一化代替层归一化,与 SNN 训练保持一致,并使用 AdamW 从零开始训练。

实验结果

研究问题

  • RQ1在 SNNs 中是否可以在不使用 softmax 和乘法的情况下有效实现自注意力?
  • RQ2基于尖峰形式的自注意力(SSA)是否能在静态和神经形态数据集上的图像分类任务中比现有的 SNNs 实现具有竞争力或更优的性能?
  • RQ3Spikformer 相对于在 ImageNet 和神经形态数据集上最先进的直接训练 SNN,其准确率和能效之间的权衡是什么?

主要发现

  • 配备 SSA 的 Spikformer 在静态和神经形态数据集上均超越了最先进的类似 SNN 的框架。
  • 在 ImageNet 上,Spikformer-8-512 在 4 个时间步内达到 73.38% top-1,Spikformer-8-768 达到 74.81% top-1,超越 SEW-ResNet-152。
  • Spikformer 在 CIFAR-10/100 和神经形态数据集(DVS128 Gesture 和 CIFAR10-DVS)上展示出具有显著更小模型和更低能耗估计的具有竞争力或更高的准确度。
  • SSA 避免 softmax 和乘法,通过尖峰形式的 Q/K/V 进行稀疏计算,导致理论能耗(SOPs)下降,同时保持或提高准确性。
  • 四块 SPS 和尖峰形式嵌入使补丁处理更有效,在不同时间步和网络规模下都具有坚韧表现。

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。