[论文解读] Contextual Transformer Networks for Visual Recognition
本文提出 Contextual Transformer (CoT) 块,通过在局部邻域内挖掘静态上下文并学习动态上下文注意力,替换 ResNet 风格骨干中的 3x3 卷积,形成 CoTNet/CoTNeXt 骨干,在 ImageNet 和 COCO 上性能提升。
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}.
研究动机与目标
- 提出动机并解决传统自注意力在二维视觉特征图上上下文建模受限的问题。
- 提出将键的静态上下文化与动态自注意力相结合的 CoT 块。
- 展示如何在 ResNet/ResNeXt 中用 CoT 块替换 3x3 卷积,构建 CoTNet/CoTNeXt 骨干。
- 展示在图像识别(ImageNet)和下游任务(COCO)上的提升。
提出的方法
- 首次通过 3x3 卷积对键进行上下文化以创建静态上下文,引入 Contextual Transformer (CoT) 块。
- 将上下文化的键与查询拼接,通过两次连续的一维 1x1 卷积学习动态多头注意力矩阵。
- 通过将注意力应用于值来计算动态上下文表示,并将静态上下文与动态上下文融合为输出。
- 将 ResNet/ResNeXt 中的每个 3x3 卷积替换为 CoT 块,形成 CoTNet 和 CoTNeXt 骨干。
- 提供诸如 CoTNet-50/101 和 CoTNeXt-50/101 的变体,并在 ImageNet 和 COCO 上与最前沿骨干进行对比。
实验结果
研究问题
- RQ1邻近键之间的上下文信息是否能提升二维视觉特征图中自注意力的学习?
- RQ2在标准骨干(ResNet/ResNeXt)中将 3x3 卷积替换为 CoT 块是否有利于识别和检测任务?
- RQ3CoTNet 与 CoTNeXt 骨干在 ImageNet 和 COCO 上相对最先进架构的性能如何?
- RQ4在使用 CoT 块时,参数、FLOPs 与准确度之间的权衡是什么?
主要发现
| 模型 | Top-1 准确率 | Top-5 准确率 | 参数 | GFLOPs |
|---|---|---|---|---|
| CoTNet-50 | 79.2 | 94.5 | 22.2M | 3.3 |
| CoTNeXt-50 | 79.5 | 94.5 | 30.1M | 4.3 |
| CoTNet-101 | 80.0 | 94.9 | 38.3M | 6.1 |
| CoTNeXt-101 | 80.3 | 95.0 | 53.4M | 8.2 |
- 在参数和 FLOPs 相当的情况下,CoT 块在 ImageNet top-1/top-5 精度上优于若干最先进的骨干网络。
- 在 ResNet/ResNeXt 骨干中用 CoT 块替换 3x3 卷积,在FLOPs 相似或更低的情况下获得更高的准确率。
- CoTNet-50、CoTNeXt-50、CoTNet-101、和 CoTNeXt-101 在默认训练设置下的 top-1 精度优于同类(例如 CoTNeXt-50 79.5% top-1、94.5% top-5)。
- 在更高级的训练下,CoTNet-50/101 和 CoTNeXt-50/101 达到更高的 top-1 准确率,其中 CoTNeXt-101 达到 83.2% top-1。
- CoTNeXt-50/101 变体在相似 FLOPs 下显示出有利的准确性,SE-CoTNetD-152 在效率竞争力方面也取得了不错的结果。
- 推理时分析表明,与若干基线相比,CoTNet 模型在精度-时间折衷方面具有更好表现。
更好的研究,从现在开始
从论文设计到论文写作,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。