第11章注意機構とTransformer
11.8.1. Model11.8.1 モデル
Fig. 11.8.1 depicts the model architecture of vision Transformers. This architecture consists of a stem that patchifies images, a body based on the multilayer Transformer encoder, and a head that transforms the global representation into the output label.
英語のヒント
図11.8.1は、視覚のTransformerのモデルの構造を描いている。この構造は、画像をパッチに分けるステム、多層のTransformerのエンコーダにもとづくボディ、大域的な表現を出力のラベルに変換するヘッドからなる。
Fig. 11.8.1図11.8.1
The vision Transformer architecture. In this example, an image is split into nine patches. A special “<cls>” token and the nine flattened image patches are transformed via patch embedding and Transformer encoder blocks into ten representations, respectively. The “<cls>” representation is further transformed into the output label.
英語のヒント
視覚のTransformerの構造。この例では、画像は九つのパッチに分けられる。特別な「<cls>」トークンと九つの平らにした画像のパッチは、パッチ埋め込みと個のTransformerのエンコーダのブロックを通じて、それぞれ十個の表現に変換される。「<cls>」の表現は、さらに出力のラベルに変換される。
Consider an input image with height , width , and channels. Specifying the patch height and width both as , the image is split into a sequence of patches, where each patch is flattened to a vector of length . In this way, image patches can be treated similarly to tokens in text sequences by Transformer encoders. A special “<cls>” (class) token and the flattened image patches are linearly projected into a sequence of vectors, summed with learnable positional embeddings. The multilayer Transformer encoder transforms input vectors into the same number of output vector representations of the same length. It works exactly the same way as the original Transformer encoder in Fig. 11.7.1, only differing in the position of normalization. Since the “<cls>” token attends to all the image patches via self-attention (see Fig. 11.6.1), its representation from the Transformer encoder output will be further transformed into the output label.
英語のヒント
高さ、幅、チャネルの入力画像を考えよう。パッチの高さと幅をどちらもと指定すると、画像は個のパッチの系列に分けられ、各パッチは長さのベクトルに平らにされる。こうして、Transformerのエンコーダは、画像のパッチをテキスト系列のトークンと同じように扱える。特別な「<cls>」(クラス)トークンと個の平らにした画像のパッチは、個のベクトルの系列へと線形に射影され、学習できる位置埋め込みと足し合わされる。多層のTransformerのエンコーダは、個の入力ベクトルを、同じ長さの同じ数の出力ベクトル表現に変換する。これは、正規化の位置が違うだけで、図11.7.1の元のTransformerのエンコーダとまったく同じように働く。「<cls>」トークンは自己注意を通じてすべての画像のパッチに注意を向けるので(図11.6.1を参照)、Transformerのエンコーダの出力でのその表現は、さらに出力のラベルに変換される。