Skip to main content
QUICK REVIEW

[論文レビュー] Transformer in Transformer

Kai Han, An Xiao|arXiv (Cornell University)|Feb 27, 2021
Advanced Neural Network Applications参考文献 51被引用数 1,010
ひとこと要約

TNTは画像パッチ内の視覚語に対する内側のトランスフォーマを導入し、局所特徴を豊かにする。ViT/DeiTの基準と比較して、妥当な FLOPs の増加で ImageNet 精度を向上させる。

ABSTRACT

Transformer is a new kind of neural architecture which encodes the input data as powerful features via the attention mechanism. Basically, the visual transformers first divide the input images into several local patches and then calculate both representations and their relationship. Since natural images are of high complexity with abundant detail and color information, the granularity of the patch dividing is not fine enough for excavating features of objects in different scales and locations. In this paper, we point out that the attention inside these local patches are also essential for building visual transformers with high performance and we explore a new architecture, namely, Transformer iN Transformer (TNT). Specifically, we regard the local patches (e.g., 16$ imes$16) as "visual sentences" and present to further divide them into smaller patches (e.g., 4$ imes$4) as "visual words". The attention of each word will be calculated with other words in the given visual sentence with negligible computational costs. Features of both words and sentences will be aggregated to enhance the representation ability. Experiments on several benchmarks demonstrate the effectiveness of the proposed TNT architecture, e.g., we achieve an 81.5% top-1 accuracy on the ImageNet, which is about 1.7% higher than that of the state-of-the-art visual transformer with similar computational cost. The PyTorch code is available at https://github.com/huawei-noah/CV-Backbones, and the MindSpore code is available at https://gitee.com/mindspore/models/tree/master/research/cv/TNT.

研究の動機と目的

  • 画像パッチ内の細かな局所構造を視覚的トランスフォーマに残す必要性を動機づける。
  • 内側の語レベルと外側の文レベルのトランスフォーマから成る Transformer-iN-Transformer (TNT) アーキテクチャを提案する。
  • TNT の計算コストと標準的なトランスフォーマと比較したパラメータ負荷を分析する。
  • 広範な実験を通じて ImageNet および下流タスクへの TNT の有効性を示す。

提案手法

  • 各画像パッチを視覚的な文として表現し、さらにそれを視覚的語に分割する。
  • 各文内の視覚語間の関係をモデル化するために内側のトランスフォーマを適用する。
  • 画像全体で文埋め込み間の関係をモデル化するために外側のトランスフォーマを使用する。
  • 外側のトランスフォーマの前に、語の埋め込みを対応する文の埋め込みに線形射影で追加する。
  • 文と語の位置エンコーディングを学習可能としたViT風の訓練とDeiT風の拡張を使用する。

実験結果

リサーチクエスチョン

  • RQ1 intra-patch(語レベル)関係をモデル化することは、パッチレベルのみのアプローチより視覚トランスフォーマの性能を改善するか。
  • RQ2内側トランスフォーマのサイズ、パッチあたりの語数、位置エンコーディングが精度と効率に与える影響は何か。
  • RQ3TNT は ImageNet および下流タスクで ViT/DeiT の基準より良い精度/ FLOPs のトレードオフを達成できるか。

主な発見

ModelResolutionParams (M)FLOPs (B)Top-1Top-5
ResNet-50224 × 22425.64.176.292.9
ResNet-152224 × 22460.211.578.394.1
RegNetY-8GF224 × 22439.28.079.9-
RegNetY-16GF224 × 22483.615.980.4-
EfficientNet-B3300 × 30012.01.881.694.9
EfficientNet-B4380 × 38019.04.282.996.4
DeiT-Ti224 × 2245.71.372.2-
TNT-Ti224 × 2246.11.473.991.9
DeiT-S224 × 22422.14.679.8-
PVT-Small224 × 22424.53.879.8-
PVT-Medium224 × 22440.06.781.2-
TNT-S224 × 22423.85.281.595.7
ViT-B/16384 × 38486.455.577.9-
DeiT-B224 × 22486.417.681.8-
T2T-ViT_t-24224 × 22463.913.282.2-
TNT-B224 × 22465.614.182.996.3
  • TNT-S は ImageNet で Top-1 が 81.5%、同程度の計算量で DeiT-S より約 1.7%高い。
  • TNT ブロックは標準トランスフォーマブロックに比べて FLOPs が約 1.14 倍、パラメータが約 1.08 倍増となり、精度が向上する。
  • TNT は ImageNet でいくつかのトランスフォーマーベースおよび CNN ベースの基準を上回り、下流データセット(CIFAR、Flowers、Pets、iNat)へ良好に転移する。
  • 文と語の位置エンコーディングは精度を大幅に向上させる。両方を用いると TNT-S で 81.5%/top-1 を達成する。
  • 内側のトランスフォーマ頭部構成(2-4 heads)とデフォルトの語数 m=16 が最適な性能を提供する(例:4 個の内側ヘッドで 81.5%)。
  • SE モジュールは TNT-S の精度を約 0.2 ポイント程度微増させる。

より良い研究を、今すぐ始めましょう

論文設計から論文執筆まで、研究時間を劇的に削減しましょう。

クレジットカード登録不要

このレビューはAIが作成し、人間の編集者が確認しました。