Skip to main content
QUICK REVIEW

[Paper Review] SpectFormer: Frequency and Attention is what you need in a Vision Transformer

Badri N. Patro, Vinay P. Namboodiri|arXiv (Cornell University)|Apr 13, 2023
Advanced Neural Network ApplicationsComputer Science53 citations
TL;DR

SpectFormer blends Fourier-based spectral layers with multi-headed self-attention in later stages to improve Vision Transformer performance, achieving state-of-the-art results on ImageNet-1K for small/base variants and strong transfer/COCO performance.

ABSTRACT

Vision transformers have been applied successfully for image recognition tasks. There have been either multi-headed self-attention based (ViT \cite{dosovitskiy2020image}, DeIT, \cite{touvron2021training}) similar to the original work in textual models or more recently based on spectral layers (Fnet\cite{lee2021fnet}, GFNet\cite{rao2021global}, AFNO\cite{guibas2021efficient}). We hypothesize that both spectral and multi-headed attention plays a major role. We investigate this hypothesis through this work and observe that indeed combining spectral and multi-headed attention layers provides a better transformer architecture. We thus propose the novel Spectformer architecture for transformers that combines spectral and multi-headed attention layers. We believe that the resulting representation allows the transformer to capture the feature representation appropriately and it yields improved performance over other transformer representations. For instance, it improves the top-1 accuracy by 2\% on ImageNet compared to both GFNet-H and LiT. SpectFormer-S reaches 84.25\% top-1 accuracy on ImageNet-1K (state of the art for small version). Further, Spectformer-L achieves 85.7\% that is the state of the art for the comparable base version of the transformers. We further ensure that we obtain reasonable results in other scenarios such as transfer learning on standard datasets such as CIFAR-10, CIFAR-100, Oxford-IIIT-flower, and Standford Car datasets. We then investigate its use in downstream tasks such of object detection and instance segmentation on the MS-COCO dataset and observe that Spectformer shows consistent performance that is comparable to the best backbones and can be further optimized and improved. Hence, we believe that combined spectral and attention layers are what are needed for vision transformers.

Motivation & Objective

  • Motivate the need to combine spectral and attention-based token mixing for image representation.
  • Design a unified SpectFormer architecture that uses spectral layers early and attention layers later.
  • Empirically validate SpectFormer against vanilla, spectral, and hierarchical transformers on ImageNet and downstream tasks.
  • Demonstrate transfer learning and object detection/segmentation performance benefits of SpectFormer.

Proposed method

  • Introduce SpectFormer with a two-part transformer block: spectral layers (FFT-based gating) for local frequency capture followed by multi-headed self-attention for global features.
  • Use a tunable alpha to control the number of spectral vs attention layers in a block.
  • Employ a patch embedding layer, positional encoding, and a classification head in a standard ViT-style pipeline.
  • Experiment with several spectral variants (FN, FGN, FNO, WGN) and find Fourier Gating Network (FGN) to be most effective.
  • Compare vanilla SpectFormer and hierarchical SpectFormer variants against DeIT, GFNet, AFNO, LiT, Swin, and PVT on ImageNet-1K and transfer datasets.

Experimental results

Research questions

  • RQ1Does mixing spectral layers with multi-headed attention outperform purely spectral or purely attention-based transformers for vision tasks?
  • RQ2What is the optimal allocation (alpha) between spectral and attention layers for best ImageNet performance?
  • RQ3How does SpectFormer perform in transfer learning scenarios (CIFAR, Flowers, Cars) compared to baselines?
  • RQ4Are SpectFormer variants effective for downstream tasks like object detection and instance segmentation on MS COCO?

Key findings

  • SpectFormer-S achieves 84.25% top-1 accuracy on ImageNet-1K for the small variant.
  • SpectFormer-L achieves 85.7% top-1 accuracy on ImageNet-1K for the base-like large variant.
  • SpectFormer outperforms GFNet, AFNO, LiT, and DeiT across sizes, with hierarchical variants delivering state-of-the-art results.
  • Fourier Gating Network (FGN) as the spectral block variant yields the best ablation results among FN, FNO, WGN, and FGN.
  • SpectFormer shows consistent transfer learning gains on CIFAR-10, CIFAR-100, Flowers, and Cars, and competitive performance on MS COCO object detection/segmentation.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.