Skip to main content
QUICK REVIEW

[Paper Review] Contextual Transformer Networks for Visual Recognition

Yehao Li, Ting Yao|arXiv (Cornell University)|Jul 26, 2021
Advanced Neural Network ApplicationsComputer Science42 citations
TL;DR

The paper introduces Contextual Transformer (CoT) blocks that mine static context among local neighbors and learn dynamic contextual attention, replacing 3x3 convolutions in ResNet-style backbones to form CoTNet/CoTNeXt backbones with improved ImageNet and COCO performance.

ABSTRACT

Transformer with self-attention has led to the revolutionizing of natural language processing field, and recently inspires the emergence of Transformer-style architecture design with competitive results in numerous computer vision tasks. Nevertheless, most of existing designs directly employ self-attention over a 2D feature map to obtain the attention matrix based on pairs of isolated queries and keys at each spatial location, but leave the rich contexts among neighbor keys under-exploited. In this work, we design a novel Transformer-style module, i.e., Contextual Transformer (CoT) block, for visual recognition. Such design fully capitalizes on the contextual information among input keys to guide the learning of dynamic attention matrix and thus strengthens the capacity of visual representation. Technically, CoT block first contextually encodes input keys via a $3 imes3$ convolution, leading to a static contextual representation of inputs. We further concatenate the encoded keys with input queries to learn the dynamic multi-head attention matrix through two consecutive $1 imes1$ convolutions. The learnt attention matrix is multiplied by input values to achieve the dynamic contextual representation of inputs. The fusion of the static and dynamic contextual representations are finally taken as outputs. Our CoT block is appealing in the view that it can readily replace each $3 imes3$ convolution in ResNet architectures, yielding a Transformer-style backbone named as Contextual Transformer Networks (CoTNet). Through extensive experiments over a wide range of applications (e.g., image recognition, object detection and instance segmentation), we validate the superiority of CoTNet as a stronger backbone. Source code is available at \url{https://github.com/JDAI-CV/CoTNet}.

Motivation & Objective

  • Motivate and address limited context modeling in traditional self-attention for 2D vision feature maps.
  • Propose CoT block that combines static contextualization of keys with dynamic self-attention.
  • Show how to replace 3x3 convolutions in ResNet/ResNeXt to build CoTNet/CoTNeXt backbones.
  • Demonstrate improved performance on image recognition (ImageNet) and downstream tasks (COCO).

Proposed method

  • Introduce Contextual Transformer (CoT) block that first contextualizes keys via a 3x3 convolution to create a static context.
  • Concatenate contextualized keys with queries and learn a dynamic multi-head attention matrix through two consecutive 1x1 convolutions.
  • Compute dynamic contextual representation by applying the attention to values and fuse static and dynamic context as output.
  • Replace each 3x3 convolution in ResNet/ResNeXt with CoT blocks to form CoTNet and CoTNeXt backbones.
  • Provide variants like CoTNet-50/101 and CoTNeXt-50/101 and compare against state-of-the-art backbones on ImageNet and COCO.

Experimental results

Research questions

  • RQ1Can contextual information among neighboring keys improve self-attention learning for 2D vision feature maps?
  • RQ2Is replacing 3x3 convolutions with CoT blocks in standard backbones (ResNet/ResNeXt) beneficial for recognition and detection tasks?
  • RQ3How do CoTNet and CoTNeXt backbones perform against state-of-the-art architectures on ImageNet and COCO?
  • RQ4What is the trade-off between parameters, FLOPs, and accuracy when using CoT blocks?

Key findings

  • CoT blocks outperform several state-of-the-art backbones in ImageNet top-1/top-5 accuracy for comparable parameters and FLOPs.
  • Replacing 3x3 convolutions with CoT blocks in ResNet/ResNeXt backbones yields higher accuracy with similar or lower FLOPs.
  • CoTNet-50, CoTNeXt-50, CoTNet-101, and CoTNeXt-101 achieve superior top-1 accuracy compared to peers under default training setup (e.g., CoTNeXt-50 79.5% top-1, 94.5% top-5).
  • Under advanced training, CoTNet-50/101 and CoTNeXt-50/101 reach higher top-1 accuracies, with CoTNeXt-101 achieving 83.2% top-1.
  • CoTNeXt-50/101 variants show favorable accuracy versus similar FLOPs, and SE-CoTNetD-152 achieves strong results with competitive efficiency.
  • Inference-time analyses indicate CoTNet models offer better accuracy-time trade-offs compared to several baselines.

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.