Fcaformer: Forward Cross Attention in Hybrid Vision Transformer

Haokui Zhang, Wenze Hu, Xiaoyu Wang
11/14/2022
11 citations
cs.CV
transformer-attention

Official code: hkzhang-git/FcaFormer (25 stars, Python, last commit 2023-08-23).

Abstract

Currently, one main research line in designing a more efficient vision transformer is reducing the computational cost of self attention modules by adopting sparse attention or using local attention windows. In contrast, we propose a different approach that aims to improve the performance of transformer-based architectures by densifying the attention pattern.

Show full abstract

Specifically, we proposed forward cross attention for hybrid vision transformer (FcaFormer), where tokens from previous blocks in the same stage are secondary used. To achieve this, the FcaFormer leverages two innovative components: learnable scale factors (LSFs) and a token merge and enhancement module (TME). The LSFs enable efficient processing of cross tokens, while the TME generates representative cross tokens. By integrating these components, the proposed FcaFormer enhances the interactions of tokens across blocks with potentially different semantics, and encourages more information flows to the lower levels. Based on the forward cross attention (Fca), we have designed a series of FcaFormer models that achieve the best trade-off between model size, computational cost, memory cost, and accuracy. For example, without the need for knowledge distillation to strengthen training, our FcaFormer achieves 83.1% top-1 accuracy on Imagenet with only 16.3 million parameters and about 3.6 billion MACs. This saves almost half of the parameters and a few computational costs while achieving 0.7% higher accuracy compared to distilled EfficientFormer.

View on arXivView PDF

Code Implementations(1)

[ICCV 2023] Source code of "Fcaformer: Forward Cross Attention in Hybrid Vision Transformer"

251Python, ShellNov 14, 20223 years ago

Similar Papers

Cite this paper

@article{zhang2022fcaformer,
  title  = {Fcaformer: Forward Cross Attention in Hybrid Vision Transformer},
  author = {Haokui Zhang and Wenze Hu and Xiaoyu Wang},
  year   = {2022},
  eprint = {2211.07198},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2211.07198}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2211.07198.svg)](https://codeofpaper.com/paper/2211.07198)

Discussion