0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Swin Transformer: Hierarchical Vision Transformer using Shifted Windowsのメモ

Last updated at Posted at 2023-08-19

Swin Transformer: Hierarchical Vision Transformer using Shifted Windows, Ze et al, 2021

  1. Introduction

    • 言語のtokenは固定スケールだが、画像ではそうではない(単語の数が固定ということ?)
    • 画像はself-attentionで2次で計算量が増えてしまう
    • →階層的な特徴マップで、画像サイズに線形計算量のSwin Transformerを提案
    • 画像を領域に区切り、その中のパッチだけでattentionする
      • 領域は変えていくので、パッチはまじりあう
      • ウィンドウ内のすべてのクエリ パッチは同じキー set1 を共有する(??)
  2. Method

    • 流れ
      1. 画像を4x4のパッチに分割→各パッチは4x4x3(ch)=48次元→C次元へ変換される(W/4×H/4×C)
      2. Swin Transformerをかける
      3. 隣接するパッチを統合(W/8×H/8×4C)
      4. 特徴変換(W/8×H/8×2C)
      5. Swin Transformerをかける
      6. 2~5を繰り返す
    • vggとかみたいに、チャネルが増えて、解像度が下がっていく
    • Shifted Window based Self-Attention
      • 普通は全パッチ間とのself-attention(global self-attention)をするので、画像だと計算量が2次で増えていく
      • ローカルウィンドウ内だけで、self-attentionすることにする
      • でもウィンドウ間の関係がとれない→ウィンドウの境界をまたぐように、別のウィンドウでもう一回ローカルself-attentionする
    • Efficient batch computation for shifted configuration
      • ウィンドウをシフトするとウィンドウ内の画像の大きさが変わって計算しづらい
      • A, B, Cみたいな部分を右下にもっていくと、ウィンドウをシフトしても、ウィンドウ内の画像の数は一緒なので、計算しやすい!(A, B, Cみたいなほんとは隣接してない部分はマスクして考慮しない)
    • Relative position bias
      • 絶対位置の全組み合わせのpeをやる代わりに、相対位置の組み合わせをpeすることで、計算量が下がる
    • Architecture Variants
      • 各モデルのバリエーションは以下。{}内は各レイヤーのswin transformerブロックの数、fig3がSwinTと思うとわかりやすい。
      • Swin-T: C = 96, layer numbers = {2, 2, 6, 2}
      • Swin-S: C = 96, layer numbers ={2, 2, 18, 2}
      • Swin-B: C = 128, layer numbers ={2, 2, 18, 2}
      • Swin-L: C = 192, layer numbers ={2, 2, 18, 2}
  3. Experiments

    • image net
      • 事前学習無し
        • imagenetの結果は同様の複雑さのDeiTより良い
        • Conv系よりわずかによい
      • 事前学習あり
        • vitよりよい
    • 絶対位置埋め込みは分類精度は上がるが、ほかのタスクは下がる。

参考

0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?