用卷积替代ViT中的注意力层,实现光学加速的高效视觉模型
ConvShareViT: Enhancing Vision Transformers with Convolutional Attention Mechanisms for Free-Space Optical Accelerators
- 用共享权重的深度卷积替换ViT的线性层,实现光学系统兼容
- 特定配置下可达到与标准ViT相当的注意力效果,理论推理速度提升3.04倍
- 适合光学计算场景,为光子神经网络提供轻量化视觉模型新思路
本文提出ConvShareViT,一种适配4f自由空间光学系统的新型深度学习架构。该模型将视觉变压器(ViT)中多头自注意力(MHSA)和多层感知机(MLPs)的线性层替换为跨输入通道共享权重的深度卷积层。通过系统分析卷积在MHSA中的行为及其对注意力机制的学习能力,实验表明,采用有效填充(valid-padded)共享卷积的配置可成功学习注意力机制,其注意力得分与标准ViT相当;而使用相同填充(same-padded)卷积的配置则表现出注意力学习局限,表现类似普通CNN。ConvShareViT专为4f光学系统优化,利用光学系统的并行性与高分辨率特性。结果表明,该模型理论上可比基于GPU的系统快3.04倍,展现出显著推理加速潜力。这证明仅通过卷积操作即可实现有效的视觉变压器,只需对结构进行性能与复杂度平衡的优化。
原文摘要 · Abstract (English)
This paper introduces ConvShareViT, a novel deep learning architecture that adapts Vision Transformers (ViTs) to the 4f free-space optical system. ConvShareViT replaces linear layers in multi-head self-attention (MHSA) and Multilayer Perceptrons (MLPs) with a depthwise convolutional layer with shared weights across input channels. Through the development of ConvShareViT, the behaviour of convolutions within MHSA and their effectiveness in learning the attention mechanism were analysed systematically. Experimental results demonstrate that certain configurations, particularly those using valid-padded shared convolutions, can successfully learn attention, achieving comparable attention scores to those obtained with standard ViTs. However, other configurations, such as those using same-padded convolutions, show limitations in attention learning and operate like regular CNNs rather than transformer models. ConvShareViT architectures are specifically optimised for the 4f optical system, which takes advantage of the parallelism and high-resolution capabilities of optical systems. Results demonstrate that ConvShareViT can theoretically achieve up to 3.04 times faster inference than GPU-based systems. This potential acceleration makes ConvShareViT an attractive candidate for future optical deep learning applications and proves that our ViT (ConvShareViT) can be employed using only the convolution operation, via the necessary optimisation of the ViT to balance performance and complexity.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。