๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Deep Learning/[๋…ผ๋ฌธ] Paper Review

VIT [AN IMAGE IS WORTH 16X16 WORDS: TRANSFORMERS FOR IMAGE RECOGNITION AT SCALE]

by ์ œ๋ฃฝ 2023. 7. 5.
728x90
๋ฐ˜์‘ํ˜•

 

 

 

๐Ÿ’ก
<๋ฒˆ์—ญ>
0. Abstract

While the Transformer architecture has become the de-facto standard for natural language processing tasks, its applications to computer vision remain limited. In vision, attention is either applied in conjunction with convolutional networks, or used to replace certain components of convolutional networks while keeping their overall structure in place. We show that this reliance on CNNs is not necessary and a pure transformer applied directly to sequences of image patches can perform very well on image classification tasks. When pre-trained on large amounts of data and transferred to multiple mid-sized or small image recognition benchmarks (ImageNet, CIFAR-100, VTAB, etc.), Vision Transformer (ViT) attains excellent results compared to state-of-the-art convolutional networks while requiring substantially fewer computational resources to train.1

Transformer ์•„ํ‚คํ…์ฒ˜๋Š” ์ž์—ฐ์–ด ์ฒ˜๋ฆฌ ์ž‘์—…์—์„œ ์‚ฌ์‹ค์ƒ์˜ ํ‘œ์ค€์ด ๋˜์—ˆ์ง€๋งŒ, ์ปดํ“จํ„ฐ ๋น„์ „์— ๋Œ€ํ•œ ์ ์šฉ์€ ์ œํ•œ์ ์ž…๋‹ˆ๋‹ค. ๋น„์ „์—์„œ๋Š” ์–ดํ…์…˜(Attention)์ด ํ•ฉ์„ฑ๊ณฑ ์‹ ๊ฒฝ๋ง(CNN)๊ณผ ํ•จ๊ป˜ ์ ์šฉ๋˜๊ฑฐ๋‚˜, ํ•ฉ์„ฑ๊ณฑ ์‹ ๊ฒฝ๋ง์˜ ์ผ๋ถ€ ๊ตฌ์„ฑ ์š”์†Œ๋ฅผ ๋Œ€์ฒดํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋˜์ง€๋งŒ, ์ „๋ฐ˜์ ์ธ ๊ตฌ์กฐ๋Š” ์œ ์ง€๋ฉ๋‹ˆ๋‹ค. ์šฐ๋ฆฌ๋Š” CNN์— ๋Œ€ํ•œ ์˜์กด์„ฑ์ด ํ•„์š”ํ•˜์ง€ ์•Š์œผ๋ฉฐ, ์ด๋ฏธ์ง€ ํŒจ์น˜(sequence of image patches)์— ์ง์ ‘ ์ ์šฉ๋œ ์ˆœ์ˆ˜ํ•œ Transformer๊ฐ€ ์ด๋ฏธ์ง€ ๋ถ„๋ฅ˜ ์ž‘์—…์—์„œ ๋งค์šฐ ์šฐ์ˆ˜ํ•œ ์„ฑ๋Šฅ์„ ๋ฐœํœ˜ํ•  ์ˆ˜ ์žˆ๋‹ค๋Š” ๊ฒƒ์„ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค. ๋Œ€๊ทœ๋ชจ ๋ฐ์ดํ„ฐ๋กœ ์‚ฌ์ „ ํ›ˆ๋ จ๋˜๊ณ  ์—ฌ๋Ÿฌ ์ค‘๊ฐ„ ๊ทœ๋ชจ ๋˜๋Š” ์ž‘์€ ์ด๋ฏธ์ง€ ์ธ์‹ ๋ฒค์น˜๋งˆํฌ(ImageNet, CIFAR-100, VTAB ๋“ฑ)๋กœ ์ „์ด(Transfer)๋œ Vision Transformer (ViT)์€ ์ตœ์ฒจ๋‹จ ํ•ฉ์„ฑ๊ณฑ ์‹ ๊ฒฝ๋ง์— ๋น„ํ•ด ์šฐ์ˆ˜ํ•œ ๊ฒฐ๊ณผ๋ฅผ ๋‹ฌ์„ฑํ•˜๋ฉด์„œ ํ›ˆ๋ จ์— ํ•„์š”ํ•œ ๊ณ„์‚ฐ ์ž์›์„ ์ƒ๋‹นํžˆ ์ค„์ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. [1]

1. Introduction

Self-attention-based architectures, in particular Transformers (Vaswani et al., 2017), have become the model of choice in natural language processing (NLP). The dominant approach is to pre-train on a large text corpus and then fine-tune on a smaller task-specific dataset (Devlin et al., 2019). Thanks to Transformers’ computational efficiency and scalability, it has become possible to train models of unprecedented size, with over 100B parameters (Brown et al., 2020; Lepikhin et al., 2020). With the models and datasets growing, there is still no sign of saturating performance. In computer vision, however, convolutional architectures remain dominant (LeCun et al., 1989; Krizhevsky et al., 2012; He et al., 2016). Inspired by NLP successes, multiple works try combining CNN-like architectures with self-attention (Wang et al., 2018; Carion et al., 2020), some replacing the convolutions entirely (Ramachandran et al., 2019; Wang et al., 2020a). The latter models, while theoretically efficient, have not yet been scaled effectively on modern hardware accelerators due to the use of specialized attention patterns. Therefore, in large-scale image recognition, classic ResNetlike architectures are still state of the art (Mahajan et al., 2018; Xie et al., 2020; Kolesnikov et al., 2020). Inspired by the Transformer scaling successes in NLP, we experiment with applying a standard Transformer directly to images, with the fewest possible modifications. To do so, we split an image into patches and provide the sequence of linear embeddings of these patches as an input to a Transformer. Image patches are treated the same way as tokens (words) in an NLP application. We train the model on image classification in supervised fashion.

์ž์—ฐ์–ด ์ฒ˜๋ฆฌ(NLP)์—์„œ๋Š” ํŠนํžˆ Transformer (Vaswani et al., 2017)์™€ ๊ฐ™์€ Self-attention ๊ธฐ๋ฐ˜ ์•„ํ‚คํ…์ฒ˜๊ฐ€ ์ฃผ๋ฅ˜ ๋ชจ๋ธ์ด ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์ฃผ์š”ํ•œ ์ ‘๊ทผ ๋ฐฉ์‹์€ ํฐ ํ…์ŠคํŠธ ๋ง๋ญ‰์น˜์—์„œ ์‚ฌ์ „ ํ›ˆ๋ จํ•œ ๋‹ค์Œ, ์ž‘์€ ์ž‘์—…๋ณ„ ๋ฐ์ดํ„ฐ์…‹์—์„œ ์„ธ๋ฐ€ํ•˜๊ฒŒ ์กฐ์ •ํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค (Devlin et al., 2019). Transformer์˜ ๊ณ„์‚ฐ ํšจ์œจ์„ฑ๊ณผ ํ™•์žฅ์„ฑ ๋•๋ถ„์— 1000์–ต ๊ฐœ ์ด์ƒ์˜ ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ๊ฐ€์ง„ ๋ชจ๋ธ์„ ํฌํ•จํ•œ ์ด์ „์— ์—†๋˜ ํฌ๊ธฐ์˜ ๋ชจ๋ธ์„ ํ›ˆ๋ จํ•˜๋Š” ๊ฒƒ์ด ๊ฐ€๋Šฅํ•ด์กŒ์Šต๋‹ˆ๋‹ค (Brown et al., 2020; Lepikhin et al., 2020). ๋ชจ๋ธ๊ณผ ๋ฐ์ดํ„ฐ์…‹์ด ๊ณ„์†ํ•ด์„œ ์ปค์ง€๋ฉด์„œ ์„ฑ๋Šฅ์ด ํฌํ™”๋˜๋Š” ๊ธฐ๋ฏธ๋Š” ์•„์ง ์—†์Šต๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ ์ปดํ“จํ„ฐ ๋น„์ „์—์„œ๋Š” ์—ฌ์ „ํžˆ ํ•ฉ์„ฑ๊ณฑ ์•„ํ‚คํ…์ฒ˜๊ฐ€ ์šฐ์„ธํ•ฉ๋‹ˆ๋‹ค (LeCun et al., 1989; Krizhevsky et al., 2012; He et al., 2016). NLP์˜ ์„ฑ๊ณต์„ ์˜๊ฐ์œผ๋กœ ํ•˜์—ฌ ์—ฌ๋Ÿฌ ์—ฐ๊ตฌ์—์„œ๋Š” CNN๊ณผ Self-attention์„ ๊ฒฐํ•ฉํ•˜๋ ค๋Š” ์‹œ๋„๋ฅผ ํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค (Wang et al., 2018; Carion et al., 2020). ์ผ๋ถ€๋Š” ํ•ฉ์„ฑ๊ณฑ์„ ์™„์ „ํžˆ ๋Œ€์ฒดํ•˜๊ธฐ๋„ ํ•ฉ๋‹ˆ๋‹ค (Ramachandran et al., 2019; Wang et al., 2020a). ๊ทธ๋Ÿฌ๋‚˜ ํ›„์ž์˜ ๋ชจ๋ธ์€ ์ด์šฉ๋˜๋Š” ํŠน์ˆ˜ํ•œ ์–ดํ…์…˜ ํŒจํ„ด ๋•Œ๋ฌธ์— ํ˜„๋Œ€์˜ ํ•˜๋“œ์›จ์–ด ๊ฐ€์†๊ธฐ์—์„œ ํšจ๊ณผ์ ์œผ๋กœ ํ™•์žฅ๋˜์ง€ ๋ชปํ•œ ์ƒํƒœ์ž…๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ ๋Œ€๊ทœ๋ชจ ์ด๋ฏธ์ง€ ์ธ์‹์—์„œ๋Š” ์ „ํ†ต์ ์ธ ResNet๊ณผ ์œ ์‚ฌํ•œ ์•„ํ‚คํ…์ฒ˜๊ฐ€ ์—ฌ์ „ํžˆ ์ตœ์ฒจ๋‹จ ๊ธฐ์ˆ ์ž…๋‹ˆ๋‹ค (Mahajan et al., 2018; Xie et al., 2020; Kolesnikov et al., 2020). NLP์—์„œ Transformer์˜ ํ™•์žฅ ์„ฑ๊ณต์— ์˜๊ฐ์„ ๋ฐ›์•„ ์ตœ์†Œํ•œ์˜ ์ˆ˜์ •์œผ๋กœ ์ง์ ‘ ์ด๋ฏธ์ง€์— Transformer๋ฅผ ์ ์šฉํ•˜๋Š” ์‹คํ—˜์„ ์ง„ํ–‰ํ•˜์˜€์Šต๋‹ˆ๋‹ค. ์ด๋ฅผ ์œ„ํ•ด ์ด๋ฏธ์ง€๋ฅผ ํŒจ์น˜(patch)๋กœ ๋ถ„ํ• ํ•˜๊ณ , ์ด๋Ÿฌํ•œ ํŒจ์น˜๋“ค์˜ ์„ ํ˜• ์ž„๋ฒ ๋”ฉ(sequence of linear embeddings)์„ Transformer์˜ ์ž…๋ ฅ์œผ๋กœ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ์ด๋ฏธ์ง€ ํŒจ์น˜๋Š” NLP ์‘์šฉํ”„๋กœ๊ทธ๋žจ์—์„œ์˜ ํ† ํฐ(๋‹จ์–ด)๊ณผ ๋™์ผํ•˜๊ฒŒ ์ฒ˜๋ฆฌ๋ฉ๋‹ˆ๋‹ค. ์šฐ๋ฆฌ๋Š” ์ง€๋„ ํ•™์Šต ๋ฐฉ์‹์œผ๋กœ ์ด๋ฏธ์ง€ ๋ถ„๋ฅ˜๋ฅผ ์œ„ํ•ด ์ด ๋ชจ๋ธ์„ ํ›ˆ๋ จ์‹œ์ผฐ์Šต๋‹ˆ๋‹ค.

When trained on mid-sized datasets such as ImageNet without strong regularization, these models yield modest accuracies of a few percentage points below ResNets of comparable size. This seemingly discouraging outcome may be expected: Transformers lack some of the inductive biases inherent to CNNs, such as translation equivariance and locality, and therefore do not generalize well when trained on insufficient amounts of data. However, the picture changes if the models are trained on larger datasets (14M-300M images). We find that large scale training trumps inductive bias. Our Vision Transformer (ViT) attains excellent results when pre-trained at sufficient scale and transferred to tasks with fewer datapoints. When pre-trained on the public ImageNet-21k dataset or the in-house JFT-300M dataset, ViT approaches or beats state of the art on multiple image recognition benchmarks. In particular, the best model reaches the accuracy of 88.55% on ImageNet, 90.72% on ImageNet-ReaL, 94.55% on CIFAR-100, and 77.63% on the VTAB suite of 19 tasks.

์ค‘๊ฐ„ ๊ทœ๋ชจ์˜ ๋ฐ์ดํ„ฐ์…‹์ธ ImageNet๊ณผ ๊ฐ™์€ ๋ฐ์ดํ„ฐ์…‹์—์„œ ๊ฐ•๋ ฅํ•œ ์ •๊ทœํ™”(regularization) ์—†์ด ํ›ˆ๋ จํ•œ ๊ฒฝ์šฐ, ์ด๋Ÿฌํ•œ ๋ชจ๋ธ์€ ๋น„์Šทํ•œ ํฌ๊ธฐ์˜ ResNet์— ๋น„ํ•ด ๋ช‡ ๊ฐœ์˜ ๋ฐฑ๋ถ„์œจ ์•„๋ž˜๋กœ ๊ฒจ์šฐ ์ค€์ˆ˜ํ•œ ์ •ํ™•๋„๋ฅผ ๋‹ฌ์„ฑํ•ฉ๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ๊ฒฐ๊ณผ๋Š” ์–ด๋Š ์ •๋„ ์˜ˆ์ƒํ•  ์ˆ˜ ์žˆ๋Š” ๊ฒฐ๊ณผ์ž…๋‹ˆ๋‹ค. Transformer๋Š” ํ•ฉ์„ฑ๊ณฑ ์‹ ๊ฒฝ๋ง(CNN)์— ๋‚ด์žฌ๋œ ์ผ๋ถ€ ์ธ๋•ํ‹ฐ๋ธŒ ๋ฐ”์ด์–ด์Šค, ์˜ˆ๋ฅผ ๋“ค์–ด ์ด๋™์— ๋Œ€ํ•œ ๋“ฑ๋ณ€์„ฑ(translation equivariance)๊ณผ ๊ตญ์†Œ์„ฑ(locality)๊ณผ ๊ฐ™์€ ํŠน์ง•์„ ๊ฐ–๊ณ  ์žˆ์ง€ ์•Š์œผ๋ฉฐ, ๋”ฐ๋ผ์„œ ๋ฐ์ดํ„ฐ๊ฐ€ ์ถฉ๋ถ„ํ•˜์ง€ ์•Š์€ ์ƒํ™ฉ์—์„œ๋Š” ์ž˜ ์ผ๋ฐ˜ํ™”๋˜์ง€ ์•Š์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

ํ•˜์ง€๋งŒ ์ƒํ™ฉ์€ ๋ฐ์ดํ„ฐ์…‹์ด ํฐ ๊ฒฝ์šฐ(1400๋งŒ~3์–ต ๊ฐœ์˜ ์ด๋ฏธ์ง€)์—๋Š” ๋‹ฌ๋ผ์ง‘๋‹ˆ๋‹ค. ๋Œ€๊ทœ๋ชจ ํ›ˆ๋ จ์€ ์ธ๋•ํ‹ฐ๋ธŒ ๋ฐ”์ด์–ด์Šค๋ฅผ ๋Šฅ๊ฐ€ํ•ฉ๋‹ˆ๋‹ค. ์šฐ๋ฆฌ์˜ Vision Transformer (ViT)๋Š” ์ถฉ๋ถ„ํ•œ ๊ทœ๋ชจ๋กœ ์‚ฌ์ „ ํ›ˆ๋ จ๋œ ํ›„, ๋ฐ์ดํ„ฐ ํฌ์ธํŠธ๊ฐ€ ์ ์€ ์ž‘์—…์— ์ „์ด(transfer)๋  ๋•Œ ์šฐ์ˆ˜ํ•œ ๊ฒฐ๊ณผ๋ฅผ ์–ป์Šต๋‹ˆ๋‹ค. ImageNet-21k ๋ฐ์ดํ„ฐ์…‹์ด๋‚˜ ๋‚ด๋ถ€ JFT-300M ๋ฐ์ดํ„ฐ์…‹์— ๋Œ€ํ•ด ์‚ฌ์ „ ํ›ˆ๋ จ๋œ ViT๋Š” ์—ฌ๋Ÿฌ ์ด๋ฏธ์ง€ ์ธ์‹ ๋ฒค์น˜๋งˆํฌ์—์„œ ์ตœ์ฒจ๋‹จ ๋ชจ๋ธ์„ ๊ฒฝ๋กœํ•˜๊ฑฐ๋‚˜ ๋Šฅ๊ฐ€ํ•ฉ๋‹ˆ๋‹ค. ํŠนํžˆ, ์ตœ์ƒ์˜ ๋ชจ๋ธ์€ ImageNet์—์„œ 88.55%, ImageNet-ReaL์—์„œ 90.72%, CIFAR-100์—์„œ 94.55%, VTAB 19๊ฐœ ์ž‘์—…์˜ ์Šค์œ„ํŠธ์—์„œ 77.63%์˜ ์ •ํ™•๋„๋ฅผ ๋‹ฌ์„ฑํ•ฉ๋‹ˆ๋‹ค.

inductive bias: ํ•™์Šต์‹œ ๋งŒ๋‚˜๋ณด์ง€ ๋ชปํ–ˆ๋˜ ์ƒํ™ฉ์— ๋Œ€ํ•ด ์ •ํ™•ํ•œ ์˜ˆ์ธก์„ ํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉํ•˜๋Š” ์ถ”๊ฐ€์ ์ธ ๊ฐ€์ •์„ ์˜๋ฏธํ•จ (์‚ฌ์ „ ์ •๋ณด๋ฅผ ํ†ตํ•ด ์ถ”๊ฐ€๋œ ๊ฐ€์ •)

  1. Vision ์ •๋ณด๋Š” ์ธ์ ‘ ํ”ฝ์…€๊ฐ„์˜ locality(๊ทผ์ ‘ ํ”ฝ์…€๋ผ๋ฆฌ์˜ ์ข…์†์„ฑ)๊ฐ€ ์กด์žฌํ•œ๋‹ค๋Š” ๊ฒƒ์„ ๋ฏธ๋ฆฌ ์•Œ๊ณ  ์žˆ๊ธฐ ๋•Œ๋ฌธ์— Conv๋Š” ์ธ์ ‘ ํ”ฝ์…€๊ฐ„์˜ ์ •๋ณด๋ฅผ ์ถ”์ถœํ•˜๊ธฐ ์œ„ํ•œ ๋ชฉ์ ์œผ๋กœ ์„ค๊ณ„๋˜์–ด Conv์˜ inductive bias๊ฐ€ local ์˜์—ญ์—์„œ spatial ์ •๋ณด๋ฅผ ์ž˜ ๋ฝ‘์•„๋ƒ„.+ transitional Invariance(์‚ฌ๋ฌผ ์œ„์น˜๊ฐ€ ๋ฐ”๋€Œ์–ด๋„ ๋™์ผ ์‚ฌ๋ฌผ ์ธ์‹)๋“ฑ์˜ ํŠน์„ฑ์„ ๊ฐ€์ง€๊ธฐ ๋•Œ๋ฌธ ์— ์ด๋ฏธ์ง€ ๋ฐ์ดํ„ฐ์— ์ ํ•ฉํ•œ ๋ชจ๋ธ์ž„
  1. ๋ฐ˜๋ฉด, MLP์˜ ๊ฒฝ์šฐ, all(input)-to-all (output) ๊ด€๊ณ„๋กœ ๋ชจ๋“  weight๊ฐ€ ๋…๋ฆฝ์ ์ด๋ฉฐ ๊ณต์œ ๋˜์ง€ ์•Š์•„ inductive bias๊ฐ€ ๋งค์šฐ ์•ฝํ•จ.
  1. Transformer๋Š” attention์„ ํ†ตํ•ด ์ž…๋ ฅ ๋ฐ์ดํ„ฐ์˜ ๋ชจ๋“  ์š”์†Œ๊ฐ„์˜ ๊ด€๊ณ„๋ฅผ ๊ณ„์‚ฐํ•˜๋ฏ€๋กœ CNN๋ณด๋‹ค๋Š” Inductive Bias๊ฐ€ ์ž‘๋‹ค๋ผ๊ณ  ํ•  ์ˆ˜ ์žˆ์Œ.

→ CNN > Transformer > Fully Connected

→ inductive bias๊ฐ€ ์ปค์งˆ์ˆ˜๋ก generalizaion์ด ๋–จ์–ด์ง (๋‘˜์€ trade off ๊ด€๊ณ„)

What is inductive bias?
8๋งŒ AI ํŒ€์ด ํ˜‘์—…ํ•˜๋Š” ๋ฐ์ดํ„ฐ ์‚ฌ์ด์–ธ์Šค ํ”Œ๋žซํผ. AI ๊ฒฝ์ง„๋Œ€ํšŒ์™€ ๋Œ€์ƒ ๋งž์ถค ์˜จ/์˜คํ”„๋ผ์ธ ๊ต์œก, ๋ฌธ์ œ ๊ธฐ๋ฐ˜ ํ•™์Šต ์„œ๋น„์Šค๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.
https://dacon.io/en/forum/405840

Transformer๋Š” Inductive Bias์ด ๋ถ€์กฑํ•˜๋‹ค๋ผ๋Š” ์˜๋ฏธ๋Š” ๋ฌด์—‡์ผ๊นŒ?
Inductive Bias๊ฐ€ ๋”ฅ๋Ÿฌ๋‹ ์•Œ๊ณ ๋ฆฌ์ฆ˜์— ๋ฏธ์น˜๋Š” ์˜ํ–ฅ์€ ๋ฌด์—‡์ผ๊นŒ……?
https://moon-walker.medium.com/transformer๋Š”-inductive-bias์ด-๋ถ€์กฑํ•˜๋‹ค๋ผ๋Š”-์˜๋ฏธ๋Š”-๋ฌด์—‡์ผ๊นŒ-4f6005d32558
2. Related Work

Transformers were proposed by Vaswani et al. (2017) for machine translation, and have since become the state of the art method in many NLP tasks. Large Transformer-based models are often pre-trained on large corpora and then fine-tuned for the task at hand: BERT (Devlin et al., 2019) uses a denoising self-supervised pre-training task, while the GPT line of work uses language modeling as its pre-training task (Radford et al., 2018; 2019; Brown et al., 2020). Naive application of self-attention to images would require that each pixel attends to every other pixel. With quadratic cost in the number of pixels, this does not scale to realistic input sizes. Thus, to apply Transformers in the context of image processing, several approximations have been tried in the past. Parmar et al. (2018) applied the self-attention only in local neighborhoods for each query pixel instead of globally. Such local multi-head dot-product self attention blocks can completely replace convolutions (Hu et al., 2019; Ramachandran et al., 2019; Zhao et al., 2020). In a different line of work, Sparse Transformers (Child et al., 2019) employ scalable approximations to global selfattention in order to be applicable to images. An alternative way to scale attention is to apply it in blocks of varying sizes (Weissenborn et al., 2019), in the extreme case only along individual axes (Ho et al., 2019; Wang et al., 2020a). Many of these specialized attention architectures demonstrate promising results on computer vision tasks, but require complex engineering to be implemented efficiently on hardware accelerators.

Transformers์€ Vaswani et al. (2017)์— ์˜ํ•ด ๊ธฐ๊ณ„ ๋ฒˆ์—ญ์„ ์œ„ํ•ด ์ œ์•ˆ๋˜์—ˆ์œผ๋ฉฐ, ๊ทธ ์ดํ›„๋กœ ๋งŽ์€ ์ž์—ฐ์–ด ์ฒ˜๋ฆฌ(NLP) ์ž‘์—…์—์„œ ์ตœ์ฒจ๋‹จ ๊ธฐ๋ฒ•์ด ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ๋Œ€๊ทœ๋ชจ Transformer ๊ธฐ๋ฐ˜ ๋ชจ๋ธ์€ ์ผ๋ฐ˜์ ์œผ๋กœ ํฐ ๋ง๋ญ‰์น˜์—์„œ ์‚ฌ์ „ ํ›ˆ๋ จ๋œ ํ›„ ํ•ด๋‹น ์ž‘์—…์— ๋Œ€ํ•ด ์„ธ๋ฐ€ ์กฐ์ •(fine-tuning)๋ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, BERT (Devlin et al., 2019)๋Š” ์˜ค์—ญ ๋ณด์ • ์ž๊ธฐ์ง€๋„ ํ•™์Šต ์‚ฌ์ „ ํ›ˆ๋ จ ์ž‘์—…์„ ์‚ฌ์šฉํ•˜๊ณ , GPT ์‹œ๋ฆฌ์ฆˆ๋Š” ์–ธ์–ด ๋ชจ๋ธ๋ง์„ ์‚ฌ์ „ ํ›ˆ๋ จ ์ž‘์—…์œผ๋กœ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค (Radford et al., 2018; 2019; Brown et al., 2020).

์ด๋ฏธ์ง€์— ๋Œ€ํ•ด self-attention์„ ๋‹จ์ˆœํžˆ ์ ์šฉํ•˜๋ฉด ๊ฐ ํ”ฝ์…€์ด ๋‹ค๋ฅธ ๋ชจ๋“  ํ”ฝ์…€์— ์ฐธ์—ฌํ•ด์•ผ ํ•œ๋‹ค๋Š” ๊ฒƒ์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค. ํ”ฝ์…€ ์ˆ˜์— ๋Œ€ํ•œ ์ด์ฐจ ๋น„์šฉ ๋•Œ๋ฌธ์— ์‹ค์ œ ์ž…๋ ฅ ํฌ๊ธฐ๋กœ ํ™•์žฅ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ ์ด๋ฏธ์ง€ ์ฒ˜๋ฆฌ์˜ ๋งฅ๋ฝ์—์„œ Transformer๋ฅผ ์ ์šฉํ•˜๊ธฐ ์œ„ํ•ด ๊ณผ๊ฑฐ์—๋Š” ์—ฌ๋Ÿฌ ๊ฐ€์ง€ ๊ทผ์‚ฌ ๋ฐฉ๋ฒ•์ด ์‹œ๋„๋˜์—ˆ์Šต๋‹ˆ๋‹ค. Parmar et al. (2018)์€ ์ „์—ญ์ ์œผ๋กœ๊ฐ€ ์•„๋‹Œ ๊ฐ ์ฟผ๋ฆฌ ํ”ฝ์…€์— ๋Œ€ํ•ด ๋กœ์ปฌ ์ด์›ƒ์—์„œ๋งŒ self-attention์„ ์ ์šฉํ–ˆ์Šต๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ๋กœ์ปฌ ๋‹ค์ค‘ ํ—ค๋“œ ์ ๊ณฑ self-attention ๋ธ”๋ก์€ ํ•ฉ์„ฑ๊ณฑ์„ ์™„์ „ํžˆ ๋Œ€์ฒดํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค (Hu et al., 2019; Ramachandran et al., 2019; Zhao et al., 2020). ๋‹ค๋ฅธ ์—ฐ๊ตฌ ๋ฐฉํ–ฅ์—์„œ Sparse Transformers (Child et al., 2019)๋Š” ์ด๋ฏธ์ง€์— ์ ์šฉ ๊ฐ€๋Šฅํ•˜๋„๋ก ํ™•์žฅ ๊ฐ€๋Šฅํ•œ ๊ทผ์‚ฌ ๋ฐฉ๋ฒ•์„ ์ „์—ญ self-attention์— ์ ์šฉํ•ฉ๋‹ˆ๋‹ค. attention์„ ํ™•์žฅํ•˜๋Š” ๋˜ ๋‹ค๋ฅธ ๋ฐฉ๋ฒ•์€ ํฌ๊ธฐ๊ฐ€ ๋‹ค๋ฅธ ๋ธ”๋ก์— ์ ์šฉํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค (Weissenborn et al., 2019), ๊ทน๋‹จ์ ์ธ ๊ฒฝ์šฐ์—๋Š” ๊ฐ๊ฐ์˜ ์ถ•์„ ๋”ฐ๋ผ๋งŒ ์ ์šฉํ•ฉ๋‹ˆ๋‹ค (Ho et al., 2019; Wang et al., 2020a). ์ด๋Ÿฌํ•œ ํŠน์ˆ˜ํ™”๋œ attention ์•„ํ‚คํ…์ฒ˜ ์ค‘ ๋งŽ์€ ๊ฒƒ๋“ค์ด ์ปดํ“จํ„ฐ ๋น„์ „ ์ž‘์—…์—์„œ ์œ ๋งํ•œ ๊ฒฐ๊ณผ๋ฅผ ๋‚˜ํƒ€๋‚ด์ง€๋งŒ, ํ•˜๋“œ์›จ์–ด ๊ฐ€์†๊ธฐ์—์„œ ํšจ์œจ์ ์œผ๋กœ ๊ตฌํ˜„ํ•˜๊ธฐ ์œ„ํ•ด ๋ณต์žกํ•œ ์—”์ง€๋‹ˆ์–ด๋ง์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.

Most related to ours is the model of Cordonnier et al. (2020), which extracts patches of size 2 × 2 from the input image and applies full self-attention on top. This model is very similar to ViT, but our work goes further to demonstrate that large scale pre-training makes vanilla transformers competitive with (or even better than) state-of-the-art CNNs. Moreover, Cordonnier et al. (2020) use a small patch size of 2 × 2 pixels, which makes the model applicable only to small-resolution images, while we handle medium-resolution images as well. There has also been a lot of interest in combining convolutional neural networks (CNNs) with forms of self-attention, e.g. by augmenting feature maps for image classification (Bello et al., 2019) or by further processing the output of a CNN using self-attention, e.g. for object detection (Hu et al., 2018; Carion et al., 2020), video processing (Wang et al., 2018; Sun et al., 2019), image classification (Wu et al., 2020), unsupervised object discovery (Locatello et al., 2020), or unified text-vision tasks (Chen et al., 2020c; Lu et al., 2019; Li et al., 2019). Another recent related model is image GPT (iGPT) (Chen et al., 2020a), which applies Transformers to image pixels after reducing image resolution and color space. The model is trained in an unsupervised fashion as a generative model, and the resulting representation can then be fine-tuned or probed linearly for classification performance, achieving a maximal accuracy of 72% on ImageNet.

Cordonnier et al. (2020)์˜ ๋ชจ๋ธ์€ ์ž…๋ ฅ ์ด๋ฏธ์ง€์—์„œ ํฌ๊ธฐ๊ฐ€ 2 × 2์ธ ํŒจ์น˜๋ฅผ ์ถ”์ถœํ•˜๊ณ  ์ด์— ๋Œ€ํ•ด ์ „์ฒด self-attention์„ ์ ์šฉํ•ฉ๋‹ˆ๋‹ค. ์ด ๋ชจ๋ธ์€ ViT์™€ ๋งค์šฐ ์œ ์‚ฌํ•˜์ง€๋งŒ, ์šฐ๋ฆฌ์˜ ์—ฐ๊ตฌ๋Š” ๋Œ€๊ทœ๋ชจ ์‚ฌ์ „ ํ›ˆ๋ จ์„ ํ†ตํ•ด ๊ธฐ๋ณธ Transformer๊ฐ€ ์ตœ์ฒจ๋‹จ CNN๊ณผ ๊ฒฝ์Ÿํ•  ์ˆ˜ ์žˆ์Œ์„ ๋” ๋‚˜์•„๊ฐ€ ์ฆ๋ช…ํ•ฉ๋‹ˆ๋‹ค. ๊ฒŒ๋‹ค๊ฐ€ Cordonnier et al. (2020)์€ 2 × 2 ํ”ฝ์…€์˜ ์ž‘์€ ํŒจ์น˜ ํฌ๊ธฐ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ชจ๋ธ์„ ์ž‘์€ ํ•ด์ƒ๋„์˜ ์ด๋ฏธ์ง€์—๋งŒ ์ ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋ฐ˜๋ฉด์— ์šฐ๋ฆฌ๋Š” ์ค‘๊ฐ„ ํ•ด์ƒ๋„ ์ด๋ฏธ์ง€๋„ ๋‹ค๋ฃฐ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๋˜ํ•œ, ํ•ฉ์„ฑ๊ณฑ ์‹ ๊ฒฝ๋ง(CNN)๊ณผ self-attention์„ ๊ฒฐํ•ฉํ•˜๋Š” ๊ฒƒ์— ๋Œ€ํ•œ ๋งŽ์€ ๊ด€์‹ฌ์ด ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, ์ด๋ฏธ์ง€ ๋ถ„๋ฅ˜๋ฅผ ์œ„ํ•ด ํŠน์ง• ๋งต์„ ๋ณด๊ฐ•ํ•˜๋Š” ๋ฐฉ์‹์ด๋‚˜ CNN์˜ ์ถœ๋ ฅ์„ self-attention์œผ๋กœ ์ถ”๊ฐ€ ์ฒ˜๋ฆฌํ•˜๋Š” ๋ฐฉ์‹ ๋“ฑ์ด ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋Š” ๊ฐ์ฒด ๊ฒ€์ถœ (Hu et al., 2018; Carion et al., 2020), ๋น„๋””์˜ค ์ฒ˜๋ฆฌ (Wang et al., 2018; Sun et al., 2019), ์ด๋ฏธ์ง€ ๋ถ„๋ฅ˜ (Wu et al., 2020), ๋น„์ง€๋„ ๊ฐ์ฒด ํƒ์ง€ (Locatello et al., 2020) ๋˜๋Š” ํ†ตํ•ฉ ํ…์ŠคํŠธ-๋น„์ „ ์ž‘์—… (Chen et al., 2020c; Lu et al., 2019; Li et al., 2019) ๋“ฑ ๋‹ค์–‘ํ•œ ์ž‘์—…์—์„œ ์‚ฌ์šฉ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

๋˜ ๋‹ค๋ฅธ ์ตœ๊ทผ์˜ ๊ด€๋ จ ๋ชจ๋ธ์€ ์ด๋ฏธ์ง€ GPT (iGPT) (Chen et al., 2020a)๋กœ, ์ด๋ฏธ์ง€ ํ•ด์ƒ๋„์™€ ์ƒ‰ ๊ณต๊ฐ„์„ ์ค„์ธ ํ›„ Transformer๋ฅผ ์ด๋ฏธ์ง€ ํ”ฝ์…€์— ์ ์šฉํ•ฉ๋‹ˆ๋‹ค. ์ด ๋ชจ๋ธ์€ ์ƒ์„ฑ ๋ชจ๋ธ๋กœ ๋น„์ง€๋„ ๋ฐฉ์‹์œผ๋กœ ํ›ˆ๋ จ๋˜๋ฉฐ, ๊ฒฐ๊ณผ์ ์ธ ํ‘œํ˜„์€ ์„ธ๋ฐ€ ์กฐ์ •(fine-tuning)์ด๋‚˜ ์„ ํ˜• ๋ถ„๋ฅ˜ ์„ฑ๋Šฅ์— ๋Œ€ํ•œ ํ”„๋กœ๋ธŒ(probe)๋กœ ์‚ฌ์šฉ๋  ์ˆ˜ ์žˆ์œผ๋ฉฐ, ImageNet์—์„œ ์ตœ๋Œ€ 72%์˜ ์ •ํ™•๋„๋ฅผ ๋‹ฌ์„ฑํ•ฉ๋‹ˆ๋‹ค.

Our work adds to the increasing collection of papers that explore image recognition at larger scales than the standard ImageNet dataset. The use of additional data sources allows to achieve state-ofthe-art results on standard benchmarks (Mahajan et al., 2018; Touvron et al., 2019; Xie et al., 2020). Moreover, Sun et al. (2017) study how CNN performance scales with dataset size, and Kolesnikov et al. (2020); Djolonga et al. (2020) perform an empirical exploration of CNN transfer learning from large scale datasets such as ImageNet-21k and JFT-300M. We focus on these two latter datasets as well, but train Transformers instead of ResNet-based models used in prior works.

์šฐ๋ฆฌ์˜ ์—ฐ๊ตฌ๋Š” ํ‘œ์ค€ ImageNet ๋ฐ์ดํ„ฐ์…‹๋ณด๋‹ค ๋” ํฐ ๊ทœ๋ชจ์˜ ์ด๋ฏธ์ง€ ์ธ์‹์„ ํƒ๊ตฌํ•˜๋Š” ๋…ผ๋ฌธ๋“ค์˜ ์ฆ๊ฐ€ํ•˜๋Š” ์ง‘ํ•ฉ์— ์ถ”๊ฐ€๋ฉ๋‹ˆ๋‹ค. ์ถ”๊ฐ€ ๋ฐ์ดํ„ฐ ์†Œ์Šค์˜ ์‚ฌ์šฉ์€ ํ‘œ์ค€ ๋ฒค์น˜๋งˆํฌ์—์„œ ์ตœ์ฒจ๋‹จ ๊ฒฐ๊ณผ๋ฅผ ๋‹ฌ์„ฑํ•˜๋Š” ๋ฐ ๋„์›€์ด ๋ฉ๋‹ˆ๋‹ค (Mahajan et al., 2018; Touvron et al., 2019; Xie et al., 2020). ๊ฒŒ๋‹ค๊ฐ€ Sun et al. (2017)์€ CNN ์„ฑ๋Šฅ์ด ๋ฐ์ดํ„ฐ์…‹ ํฌ๊ธฐ์— ๋”ฐ๋ผ ์–ด๋–ป๊ฒŒ ์Šค์ผ€์ผ๋˜๋Š”์ง€์— ๋Œ€ํ•ด ์—ฐ๊ตฌํ•˜์˜€๊ณ , Kolesnikov et al. (2020) ๋ฐ Djolonga et al. (2020)์€ ImageNet-21k ๋ฐ JFT-300M๊ณผ ๊ฐ™์€ ๋Œ€๊ทœ๋ชจ ๋ฐ์ดํ„ฐ์…‹์œผ๋กœ๋ถ€ํ„ฐ์˜ CNN ์ „์ด ํ•™์Šต์— ๋Œ€ํ•ด ๊ฒฝํ—˜์ ์œผ๋กœ ํƒ๊ตฌํ•˜์˜€์Šต๋‹ˆ๋‹ค. ์šฐ๋ฆฌ๋Š” ์ดํ›„์˜ ์ž‘์—…์—์„œ ์‚ฌ์šฉ๋œ ResNet ๊ธฐ๋ฐ˜ ๋ชจ๋ธ ๋Œ€์‹ ์— Transformer๋ฅผ ํ›ˆ๋ จ์‹œํ‚ด์œผ๋กœ์จ ์ด ๋‘ ๋ฐ์ดํ„ฐ์…‹์— ์ง‘์ค‘ํ•ฉ๋‹ˆ๋‹ค.

Figure 1: Model overview. We split an image into fixed-size patches, linearly embed each of them, add position embeddings, and feed the resulting sequence of vectors to a standard Transformer encoder. In order to perform classification, we use the standard approach of adding an extra learnable “classification token” to the sequence. The illustration of the Transformer encoder was inspired by Vaswani et al. (2017).

Figure 1: ๋ชจ๋ธ ๊ฐœ์š”. ์šฐ๋ฆฌ๋Š” ์ด๋ฏธ์ง€๋ฅผ ๊ณ ์ • ํฌ๊ธฐ์˜ ํŒจ์น˜๋กœ ๋‚˜๋ˆ„๊ณ , ๊ฐ๊ฐ์„ ์„ ํ˜•์œผ๋กœ ์ž„๋ฒ ๋”ฉํ•˜๊ณ , ์œ„์น˜ ์ž„๋ฒ ๋”ฉ์„ ์ถ”๊ฐ€ํ•œ ํ›„, ๊ฒฐ๊ณผ์ ์ธ ๋ฒกํ„ฐ ์‹œํ€€์Šค๋ฅผ ํ‘œ์ค€ Transformer ์ธ์ฝ”๋”์— ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค. ๋ถ„๋ฅ˜๋ฅผ ์ˆ˜ํ–‰ํ•˜๊ธฐ ์œ„ํ•ด, ์‹œํ€€์Šค์— ํ•™์Šต ๊ฐ€๋Šฅํ•œ "๋ถ„๋ฅ˜ ํ† ํฐ"์„ ์ถ”๊ฐ€ํ•˜๋Š” ํ‘œ์ค€์ ์ธ ์ ‘๊ทผ ๋ฐฉ์‹์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. Transformer ์ธ์ฝ”๋”์˜ ๊ทธ๋ฆผ์€ Vaswani et al. (2017)์— ์˜๊ฐ์„ ๋ฐ›์•„ ์ž‘์„ฑ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

3. Method

In model design we follow the original Transformer (Vaswani et al., 2017) as closely as possible. An advantage of this intentionally simple setup is that scalable NLP Transformer architectures – and their efficient implementations – can be used almost out of the box.

๋ชจ๋ธ ๋””์ž์ธ์—์„œ๋Š” ๊ฐ€๋Šฅํ•œ ํ•œ ์›๋ž˜์˜ Transformer (Vaswani et al., 2017)๋ฅผ ๋”ฐ๋ฅด๋„๋ก ๋…ธ๋ ฅํ–ˆ์Šต๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ์˜๋„์ ์œผ๋กœ ๊ฐ„๋‹จํ•œ ์„ค์ •์˜ ์žฅ์ ์€ ํ™•์žฅ ๊ฐ€๋Šฅํ•œ NLP Transformer ์•„ํ‚คํ…์ฒ˜์™€ ํšจ์œจ์ ์ธ ๊ตฌํ˜„์ด ๊ฑฐ์˜ ๊ทธ๋Œ€๋กœ ์‚ฌ์šฉ๋  ์ˆ˜ ์žˆ๋‹ค๋Š” ์ ์ž…๋‹ˆ๋‹ค.

3.1 VISION TRANSFORMER (VIT)

An overview of the model is depicted in Figure 1. The standard Transformer receives as input a 1D sequence of token embeddings. To handle 2D images, we reshape the image x ∈ R H×W×C into a sequence of flattened 2D patches xp ∈ R N×(P 2 ·C) , where (H, W) is the resolution of the original image, C is the number of channels, (P, P) is the resolution of each image patch, and N = HW/P2 is the resulting number of patches, which also serves as the effective input sequence length for the Transformer. The Transformer uses constant latent vector size D through all of its layers, so we flatten the patches and map to D dimensions with a trainable linear projection (Eq. 1). We refer to the output of this projection as the patch embeddings.

Similar to BERT’s [class] token, we prepend a learnable embedding to the sequence of embedded patches (z 0 0 = xclass), whose state at the output of the Transformer encoder (z 0 L ) serves as the image representation y (Eq. 4). Both during pre-training and fine-tuning, a classification head is attached to z 0 L . The classification head is implemented by a MLP with one hidden layer at pre-training time and by a single linear layer at fine-tuning time. Position embeddings are added to the patch embeddings to retain positional information. We use standard learnable 1D position embeddings, since we have not observed significant performance gains from using more advanced 2D-aware position embeddings (Appendix D.4). The resulting sequence of embedding vectors serves as input to the encoder.

Figure 1์—์„œ ๋ชจ๋ธ์˜ ๊ฐœ์š”๋ฅผ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค. ํ‘œ์ค€ Transformer๋Š” 1D ํ† ํฐ ์ž„๋ฒ ๋”ฉ ์‹œํ€€์Šค๋ฅผ ์ž…๋ ฅ์œผ๋กœ ๋ฐ›์Šต๋‹ˆ๋‹ค. 2D ์ด๋ฏธ์ง€๋ฅผ ์ฒ˜๋ฆฌํ•˜๊ธฐ ์œ„ํ•ด ์ด๋ฏธ์ง€ x ∈ R H×W×C๋ฅผ ํ‰ํƒ„ํ™”๋œ 2D ํŒจ์น˜ ์‹œํ€€์Šค xp ∈ R N×(P 2 ·C)๋กœ ์žฌ๊ตฌ์„ฑํ•ฉ๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์„œ (H, W)๋Š” ์›๋ž˜ ์ด๋ฏธ์ง€์˜ ํ•ด์ƒ๋„, C๋Š” ์ฑ„๋„์˜ ์ˆ˜, (P, P)๋Š” ๊ฐ ์ด๋ฏธ์ง€ ํŒจ์น˜์˜ ํ•ด์ƒ๋„๋ฅผ ๋‚˜ํƒ€๋‚ด๋ฉฐ, N = HW/P2๋Š” ํŒจ์น˜์˜ ๊ฐœ์ˆ˜๋กœ์„œ Transformer์˜ ์œ ํšจํ•œ ์ž…๋ ฅ ์‹œํ€€์Šค ๊ธธ์ด๋กœ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. Transformer๋Š” ๋ชจ๋“  ๋ ˆ์ด์–ด์—์„œ ์ผ์ •ํ•œ ์ž ์žฌ ๋ฒกํ„ฐ ํฌ๊ธฐ D๋ฅผ ์‚ฌ์šฉํ•˜๋ฏ€๋กœ, ํŒจ์น˜๋ฅผ ํ‰ํƒ„ํ™”ํ•˜๊ณ  ํ•™์Šต ๊ฐ€๋Šฅํ•œ ์„ ํ˜• ๋ณ€ํ™˜(Eq. 1)์„ ์‚ฌ์šฉํ•˜์—ฌ D ์ฐจ์›์œผ๋กœ ๋งคํ•‘ํ•ฉ๋‹ˆ๋‹ค. ์ด ๋ณ€ํ™˜์˜ ์ถœ๋ ฅ์„ ํŒจ์น˜ ์ž„๋ฒ ๋”ฉ์ด๋ผ๊ณ  ํ•ฉ๋‹ˆ๋‹ค.

Similar to BERT’s [class] token, we prepend a learnable embedding to the sequence of embedded patches (z 0 0 = xclass), whose state at the output of the Transformer encoder (z 0 L ) serves as the image representation y (Eq. 4). Both during pre-training and fine-tuning, a classification head is attached to z 0 L . The classification head is implemented by a MLP with one hidden layer at pre-training time and by a single linear layer at fine-tuning time. Position embeddings are added to the patch embeddings to retain positional information. We use standard learnable 1D position embeddings, since we have not observed significant performance gains from using more advanced 2D-aware position embeddings (Appendix D.4). The resulting sequence of embedding vectors serves as input to the encoder.

The Transformer encoder (Vaswani et al., 2017) consists of alternating layers of multiheaded selfattention (MSA, see Appendix A) and MLP blocks (Eq. 2, 3). Layernorm (LN) is applied before every block, and residual connections after every block (Wang et al., 2019; Baevski & Auli, 2019). The MLP contains two layers with a GELU non-linearity.

BERT์™€ ์œ ์‚ฌํ•˜๊ฒŒ, ์ž„๋ฒ ๋”ฉ๋œ ํŒจ์น˜ ์‹œํ€€์Šค์— ํ•™์Šต ๊ฐ€๋Šฅํ•œ ์ž„๋ฒ ๋”ฉ์„ ์•ž์— ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค (z 0 0 = xclass). Transformer ์ธ์ฝ”๋”์˜ ์ถœ๋ ฅ ์ƒํƒœ (z 0 L)๋Š” ์ด๋ฏธ์ง€ ํ‘œํ˜„ y๋กœ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค (Eq. 4). ์‚ฌ์ „ ํ›ˆ๋ จ ๋ฐ ์„ธ๋ถ€ ์กฐ์ • ๋™์•ˆ์—๋Š” ๋ถ„๋ฅ˜ ํ—ค๋“œ๊ฐ€ z 0 L์— ์—ฐ๊ฒฐ๋ฉ๋‹ˆ๋‹ค. ๋ถ„๋ฅ˜ ํ—ค๋“œ๋Š” ์‚ฌ์ „ ํ›ˆ๋ จ ์‹œ์—๋Š” ํ•˜๋‚˜์˜ ์€๋‹‰์ธต์„ ๊ฐ€์ง„ MLP๋กœ ๊ตฌํ˜„๋˜๊ณ , ์„ธ๋ถ€ ์กฐ์ • ์‹œ์—๋Š” ๋‹จ์ผ ์„ ํ˜• ์ธต์œผ๋กœ ๊ตฌํ˜„๋ฉ๋‹ˆ๋‹ค.

์œ„์น˜ ์ž„๋ฒ ๋”ฉ์€ ํŒจ์น˜ ์ž„๋ฒ ๋”ฉ์— ์ถ”๊ฐ€๋˜์–ด ์œ„์น˜ ์ •๋ณด๋ฅผ ๋ณด์กดํ•ฉ๋‹ˆ๋‹ค. ์šฐ๋ฆฌ๋Š” ๊ณ ๊ธ‰ 2D-aware ์œ„์น˜ ์ž„๋ฒ ๋”ฉ์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ๋ณด๋‹ค ํ‘œ์ค€ ํ•™์Šต ๊ฐ€๋Šฅํ•œ 1D ์œ„์น˜ ์ž„๋ฒ ๋”ฉ์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. (๋ถ€๋ก D.4 ์ฐธ์กฐ) ๋ง๋ถ™์—ฌ์„œ, ์ž„๋ฒ ๋”ฉ ๋ฒกํ„ฐ์˜ ๊ฒฐ๊ณผ ์‹œํ€€์Šค๋Š” ์ธ์ฝ”๋”์˜ ์ž…๋ ฅ์œผ๋กœ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.

→ 1D positional embedding: ์™ผ์ชฝ ์œ„๋ถ€ํ„ฐ ์˜ค๋ฅธ์ชฝ ์•„๋ž˜์™€ ๊ฐ™์ด ์ฐจ๋ก€๋กœ ์ˆœ์„œ๋ฅผ ๋งค๊ธฐ๋Š” ๊ฒƒ์„ ์˜๋ฏธ

→ 2D positional embedding: 2์ฐจ์›์— ๋Œ€ํ•ด x,y์ถ•์— ๋Œ€ํ•œ ์ขŒํ‘œ๊ฐ€ ์žˆ๋Š” positional embedding

→ relative positional embedding: ํŒจ์น˜๋“ค ์‚ฌ์ด์˜ ์ƒ๋Œ€์  ๊ฑฐ๋ฆฌ๋ฅผ ํ™œ์šฉํ•œ positional embedding

Transformer ์ธ์ฝ”๋” (Vaswani et al., 2017)๋Š” ๋‹ค์ค‘ ํ—ค๋“œ ์…€ํ”„ ์–ดํ…์…˜(MSA, ๋ถ€๋ก A ์ฐธ์กฐ)๊ณผ MLP ๋ธ”๋ก(Eq. 2, 3)์ด ๋ฒˆ๊ฐˆ์•„ ๋‚˜์˜ค๋Š” ์—ฌ๋Ÿฌ ๊ฐœ์˜ ์ธต์œผ๋กœ ๊ตฌ์„ฑ๋ฉ๋‹ˆ๋‹ค. ๊ฐ ์ธต์€ ๋ ˆ์ด์–ด ์ •๊ทœํ™”(LN)๊ฐ€ ์•ž์— ์ ์šฉ๋˜๋ฉฐ, ์ž”์ฐจ ์—ฐ๊ฒฐ์ด ๊ฐ ๋ธ”๋ก ๋’ค์— ์ ์šฉ๋ฉ๋‹ˆ๋‹ค. (Wang et al., 2019; Baevski & Auli, 2019).

MLP ๋ธ”๋ก์€ ๋‘ ๊ฐœ์˜ ์™„์ „ ์—ฐ๊ฒฐ์ธต์œผ๋กœ ๊ตฌ์„ฑ๋˜๋ฉฐ, GELU ๋น„์„ ํ˜•์„ฑ์„ ๊ฐ€์ง€๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. GELU ํ™œ์„ฑํ™” ํ•จ์ˆ˜๋Š” ๋”ฅ๋Ÿฌ๋‹ ๋ชจ๋ธ์—์„œ ๋น„์„ ํ˜•์„ฑ์„ ๋„์ž…ํ•˜์—ฌ ๋ฐ์ดํ„ฐ์˜ ๋ณต์žกํ•œ ๊ด€๊ณ„๋ฅผ ํฌ์ฐฉํ•˜๋Š” ๋ฐ ํšจ๊ณผ์ ์œผ๋กœ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.

→ z0: patch์— ๋Œ€ํ•œ ์ •๋ณด + position embedding์˜ ํ•ฉ

→ z’l: normalization์„ ์ง„ํ–‰ํ•˜๊ณ , multi-head self- attention ์ˆ˜ํ–‰ํ•œ ํ›„, ์ž”์ฐจ ๋”ํ•ด์คŒ

→ zl: normalization ํ•œ ๋ฒˆ ๋” ์ˆ˜ํ–‰ ํ›„, MLP ์ ์šฉ ํ›„, ์ž”์ฐจ ๋”ํ•ด์คŒ

→ y: ๋งˆ์ง€๋ง‰ ์˜ˆ์ธก๊ฐ’์— normalization ํ•œ ๋ฒˆ ๋” ์ ์šฉ

 

Inductive bias. We note that Vision Transformer has much less image-specific inductive bias than CNNs. In CNNs, locality, two-dimensional neighborhood structure, and translation equivariance are baked into each layer throughout the whole model. In ViT, only MLP layers are local and translationally equivariant, while the self-attention layers are global. The two-dimensional neighborhood structure is used very sparingly: in the beginning of the model by cutting the image into patches and at fine-tuning time for adjusting the position embeddings for images of different resolution (as described below). Other than that, the position embeddings at initialization time carry no information about the 2D positions of the patches and all spatial relations between the patches have to be learned from scratch.

์ธ์‹ ํŽธํ–ฅ

Vision Transformer๋Š” CNN์— ๋น„ํ•ด ์ด๋ฏธ์ง€ ํŠน์ • ์ธ์‹ ํŽธํ–ฅ์ด ํ›จ์”ฌ ์ ์Šต๋‹ˆ๋‹ค. CNN์—์„œ๋Š” ๊ฐ ๋ ˆ์ด์–ด๋งˆ๋‹ค ์ง€์—ญ์„ฑ(locality), 2์ฐจ์› ์ด์›ƒ ๊ตฌ์กฐ, ์ด๋™ ๋ถˆ๋ณ€์„ฑ(translation equivariance)์ด ์ „์ฒด ๋ชจ๋ธ์— ๋‚ด์žฌ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ๋ฐ˜๋ฉด์— ViT์—์„œ๋Š” MLP(Multi-Layer Perceptron) ๋ ˆ์ด์–ด๋งŒ ์ง€์—ญ์ ์ด๊ณ  ์ด๋™ ๋ถˆ๋ณ€์„ฑ์„ ๊ฐ€์ง€๋ฉฐ, self-attention ๋ ˆ์ด์–ด๋Š” ์ „์—ญ์ ์ž…๋‹ˆ๋‹ค. 2์ฐจ์› ์ด์›ƒ ๊ตฌ์กฐ๋Š”

๋งค์šฐ ์ œํ•œ์ ์œผ๋กœ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. ์ด๋ฏธ์ง€๋ฅผ ํŒจ์น˜(patch)๋กœ ์ž˜๋ผ๋‚ด์–ด ๋ชจ๋ธ์˜ ์‹œ์ž‘ ๋ถ€๋ถ„์—์„œ ์‚ฌ์šฉํ•˜๊ณ 

, fine-tuning ์‹œ์—๋Š” ๋‹ค๋ฅธ ํ•ด์ƒ๋„๋ฅผ ๊ฐ€์ง„ ์ด๋ฏธ์ง€์— ๋Œ€ํ•ด ์œ„์น˜ ์ž„๋ฒ ๋”ฉ์„ ์กฐ์ •ํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค (์•„๋ž˜์—์„œ ์„ค๋ช…๋จ). ์ดˆ๊ธฐํ™” ๋‹จ๊ณ„์—์„œ ์œ„์น˜ ์ž„๋ฒ ๋”ฉ์€ ํŒจ์น˜์˜ 2D ์œ„์น˜์— ๋Œ€ํ•œ ์ •๋ณด๋ฅผ ์ „๋‹ฌํ•˜์ง€ ์•Š์œผ๋ฉฐ, ํŒจ์น˜ ๊ฐ„์˜ ๋ชจ๋“  ๊ณต๊ฐ„ ๊ด€๊ณ„๋Š” ์ฒ˜์Œ๋ถ€ํ„ฐ ํ•™์Šต๋˜์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

→ VIT์—์„œ์˜ MLP๋Š” ์ด๋ฏธ input์—์„œ ํŒจ์น˜ ๋‹จ์œ„๋กœ ์ž…๋ ฅ๊ฐ’์„ ๋ฐ›๊ธฐ์— ์ •๋ณด๊ฐ€ ์กด์žฌํ•จ.

→ self attention ๋ ˆ์ด์–ด๋Š” ์ž…๋ ฅ ์‹œํ€€์Šค์˜ ๋ชจ๋“  ์œ„์น˜ ๊ฐ„์˜ ์ƒํ˜ธ์ž‘์šฉ์„ ์ˆ˜ํ–‰ํ•จ.

โ€ป Self-attention์€ ์ž…๋ ฅ ์‹œํ€€์Šค ๋‚ด์˜ ๊ฐ ์œ„์น˜๊ฐ€ ๋‹ค๋ฅธ ์œ„์น˜์™€ ์–ผ๋งˆ๋‚˜ ๊ด€๋ จ๋˜์–ด ์žˆ๋Š”์ง€๋ฅผ ๊ณ„์‚ฐํ•˜์—ฌ ์ค‘์š”๋„๋ฅผ ๋ถ€์—ฌํ•จ. ์ด๋ฅผ ํ†ตํ•ด ์‹œํ€€์Šค ๋‚ด์˜ ์ž„์˜์˜ ์œ„์น˜๊ฐ€ ์ „์ฒด ์‹œํ€€์Šค์˜ ๋‹ค๋ฅธ ์œ„์น˜์™€ ์ƒํ˜ธ์ž‘์šฉํ•  ์ˆ˜ ์žˆ์Œ. ๋”ฐ๋ผ์„œ self-attention์€ ์ž…๋ ฅ ์‹œํ€€์Šค์˜ ๊ธธ์ด๋‚˜ ์œ„์น˜์— ๋Œ€ํ•ด ์ƒ๊ด€์—†์ด ๋ชจ๋“  ์œ„์น˜ ๊ฐ„์˜ ๊ด€๊ณ„๋ฅผ ๋ชจ๋ธ๋งํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ, ์ด๋ฅผ ํ†ตํ•ด ์ „์—ญ์ ์ธ ์ •๋ณด๋ฅผ ์ €์žฅํ•  ์ˆ˜ ์žˆ์Œ.

โ€ป ๋ฐ˜๋ฉด์— MLP ๋ ˆ์ด์–ด๋Š” ์ž…๋ ฅ ์œ„์น˜์™€ ์ง์ ‘์ ์œผ๋กœ ์—ฐ๊ฒฐ๋˜์–ด ์žˆ์œผ๋ฉฐ, ์ง€์—ญ์ ์ธ ํŠน์ง•์„ ๋ชจ๋ธ๋งํ•จ. ์ด ๋ ˆ์ด์–ด๋Š” ์ž…๋ ฅ ์œ„์น˜์— ๋Œ€ํ•œ ํŠน์ง• ๋ณ€ํ™˜์„ ์ˆ˜ํ–‰ํ•˜๋ฏ€๋กœ, ์ด๋™ ๋ถˆ๋ณ€์„ฑ์„ ๊ฐ€์ง€๊ฒŒ ๋จ. MLP๋Š” ์ž…๋ ฅ ์œ„์น˜์— ๋Œ€ํ•ด ๋…๋ฆฝ์ ์œผ๋กœ ์ž‘๋™ํ•˜๋ฉฐ, ์ž…๋ ฅ์˜ ์ˆœ์„œ๋‚˜ ์œ„์น˜์— ์˜ํ–ฅ์„ ๋ฐ›์ง€ ์•Š์Œ.

 

โ€ป ์•„๋ž˜ ๋‘ ๊ฐ€์ง€ ๋ฐฉ์‹์„ ํ†ตํ•ด inductive bias๊ฐ€ ์ฃผ์ž…๋๋‹ค๋ผ๊ณ  ๋งํ•  ์ˆ˜ ์žˆ์Œ

→ patch extraction: ํŒจ์น˜ ๋‹จ์œ„๋กœ ๋ถ„ํ• ํ•˜์—ฌ, ์ˆœ์„œ๊ฐ€ ์กด์žฌํ•˜๋Š” ํ˜•ํƒœ๋กœ ์ž…๋ ฅ์— ๋„ฃ์Œ → ์ด๋ฅผ ํ†ตํ•ด ๊ธฐ์กด MLP์™€๋Š” ๋‹ค๋ฅด๊ฒŒ, locality์™€ translation equivariance๊ฐ€ ๋‚ด์žฌ๋จ.

→ resolution adjustment: fine tuning ์‹œ์— ์ง„ํ–‰๋จ. ์ด๋ฏธ์ง€์˜ ํฌ๊ธฐ์— ๋”ฐ๋ผ ํŒจ์น˜ ํฌ๊ธฐ๋Š” ๋™์ผํ•˜์ง€๋งŒ, ์ƒ์„ฑ๋˜๋Š” ํŒจ์น˜ ๊ฐœ์ˆ˜๊ฐ€ ๋‹ฌ๋ผ์ง€๊ธฐ์—, positional embedding์„ ์กฐ์ •ํ•ด์•ผ๋จ → ์ด๋ฅผ ํ†ตํ•ด inductive bias๊ฐ€ ์ฃผ์ž….

 

Hybrid Architecture. As an alternative to raw image patches, the input sequence can be formed from feature maps of a CNN (LeCun et al., 1989). In this hybrid model, the patch embedding projection E (Eq. 1) is applied to patches extracted from a CNN feature map. As a special case, the patches can have spatial size 1x1, which means that the input sequence is obtained by simply flattening the spatial dimensions of the feature map and projecting to the Transformer dimension. The classification input embedding and position embeddings are added as described above.

ํ˜ผํ•ฉ ์•„ํ‚คํ…์ฒ˜

์›์‹œ ์ด๋ฏธ์ง€ ํŒจ์น˜ ๋Œ€์‹ , ์ž…๋ ฅ ์‹œํ€€์Šค๋ฅผ CNN (LeCun et al., 1989)์˜ ํ”ผ์ณ ๋งต(feature map)์œผ๋กœ๋ถ€ํ„ฐ ๊ตฌ์„ฑํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ํ˜ผํ•ฉ ๋ชจ๋ธ์—์„œ๋Š” ํŒจ์น˜ ์ž„๋ฒ ๋”ฉ ํˆฌ์˜ E (์‹ 1)์ด CNN ํ”ผ์ณ ๋งต์—์„œ ์ถ”์ถœํ•œ ํŒจ์น˜์— ์ ์šฉ๋ฉ๋‹ˆ๋‹ค. ํŠน๋ณ„ํ•œ ๊ฒฝ์šฐ๋กœ, ํŒจ์น˜์˜ ๊ณต๊ฐ„ ํฌ๊ธฐ๊ฐ€ 1x1์ธ ๊ฒฝ์šฐ ์ž…๋ ฅ ์‹œํ€€์Šค๋Š” ๋‹จ์ˆœํžˆ ํ”ผ์ณ ๋งต์˜ ๊ณต๊ฐ„ ์ฐจ์›์„ ํŽผ์ณ์„œ Transformer ์ฐจ์›์œผ๋กœ ํˆฌ์˜ํ•˜๋Š” ๊ฒƒ์œผ๋กœ ์–ป์–ด์ง‘๋‹ˆ๋‹ค. ๋ถ„๋ฅ˜ ์ž…๋ ฅ ์ž„๋ฒ ๋”ฉ๊ณผ ์œ„์น˜ ์ž„๋ฒ ๋”ฉ์€ ์œ„์—์„œ ์„ค๋ช…ํ•œ ๋Œ€๋กœ ์ถ”๊ฐ€๋ฉ๋‹ˆ๋‹ค.

 

→ VIT๋Š” raw image๊ฐ€ ์•„๋‹Œ CNN์œผ๋กœ ์ถ”์ถœํ•œ raw image์˜ feature map์„ ํ™œ์šฉํ•˜๋Š” hybrid architecture๋กœ๋„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Œ

→ feature map์˜ ๊ฒฝ์šฐ, ์ด๋ฏธ raw image์˜ ๊ณต๊ฐ„์  ์ •๋ณด๋ฅผ ํฌํ•จํ•˜๊ณ  ์žˆ๊ธฐ์— hybrid architecture๋Š” ํŒจ์น˜ ํฌ๊ธฐ๋ฅผ 1x1๋กœ ์„ค์ •ํ•ด๋„ ๋จ

→ 1x1 ํŒจ์น˜๋ฅผ ์‚ฌ์šฉํ•  ๊ฒฝ์šฐ ํ”ผ์ฒ˜๋งต์˜ ๊ณต๊ฐ„ ์ฐจ์›์„ flattenํ•˜์—ฌ ๊ฐ ๋ฒกํ„ฐ์— linear projection ์ ์šฉํ•˜๋ฉด ๋จ

 

3.2 FINE-TUNING AND HIGHER RESOLUTION Typically, we pre-train ViT on large datasets, and fine-tune to (smaller) downstream tasks. For this, we remove the pre-trained prediction head and attach a zero-initialized D × K feedforward layer, where K is the number of downstream classes. It is often beneficial to fine-tune at higher resolution than pre-training (Touvron et al., 2019; Kolesnikov et al., 2020). When feeding images of higher resolution, we keep the patch size the same, which results in a larger effective sequence length. The Vision Transformer can handle arbitrary sequence lengths (up to memory constraints), however, the pre-trained position embeddings may no longer be meaningful. We therefore perform 2D interpolation of the pre-trained position embeddings, according to their location in the original image. Note that this resolution adjustment and patch extraction are the only points at which an inductive bias about the 2D structure of the images is manually injected into the Vision Transformer.

3.2 ํŒŒ์ธํŠœ๋‹๊ณผ ๊ณ ํ•ด์ƒ๋„ ์ผ๋ฐ˜์ ์œผ๋กœ, ์šฐ๋ฆฌ๋Š” ViT๋ฅผ ๋Œ€๊ทœ๋ชจ ๋ฐ์ดํ„ฐ์…‹์—์„œ ์‚ฌ์ „ ํ›ˆ๋ จํ•œ ํ›„ (๋” ์ž‘์€) ํ•˜์œ„ ์ž‘์—…์— ๋Œ€ํ•ด ํŒŒ์ธํŠœ๋‹ํ•ฉ๋‹ˆ๋‹ค. ์ด๋ฅผ ์œ„ํ•ด, ์‚ฌ์ „ ํ›ˆ๋ จ๋œ ์˜ˆ์ธก ํ—ค๋“œ๋ฅผ ์ œ๊ฑฐํ•˜๊ณ  ์˜๋ฒกํ„ฐ๋กœ ์ดˆ๊ธฐํ™”๋œ D × K ํ”ผ๋“œํฌ์›Œ๋“œ ๋ ˆ์ด์–ด๋ฅผ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์„œ K๋Š” ํ•˜์œ„ ์ž‘์—…์˜ ํด๋ž˜์Šค ์ˆ˜์ž…๋‹ˆ๋‹ค. ์‚ฌ์ „ ํ›ˆ๋ จ๋ณด๋‹ค ๋” ๋†’์€ ํ•ด์ƒ๋„์—์„œ ํŒŒ์ธํŠœ๋‹ํ•˜๋Š” ๊ฒƒ์ด ์ข…์ข… ์œ ๋ฆฌํ•ฉ๋‹ˆ๋‹ค (Touvron et al., 2019; Kolesnikov et al., 2020). ๋” ๋†’์€ ํ•ด์ƒ๋„์˜ ์ด๋ฏธ์ง€๋ฅผ ์ž…๋ ฅํ•  ๋•Œ, ํŒจ์น˜ ํฌ๊ธฐ๋Š” ๋™์ผํ•˜๊ฒŒ ์œ ์ง€ํ•˜๋ฉฐ, ์ด๋กœ ์ธํ•ด ๋” ํฐ ์œ ํšจํ•œ ์‹œํ€€์Šค ๊ธธ์ด๊ฐ€ ์ƒ์„ฑ๋ฉ๋‹ˆ๋‹ค. Vision Transformer๋Š” ์ž„์˜์˜ ์‹œํ€€์Šค ๊ธธ์ด๋ฅผ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ์ง€๋งŒ, ์‚ฌ์ „ ํ›ˆ๋ จ๋œ ์œ„์น˜ ์ž„๋ฒ ๋”ฉ์€ ๋” ์ด์ƒ ์˜๋ฏธ๊ฐ€ ์—†์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ, ์‚ฌ์ „ ํ›ˆ๋ จ๋œ ์œ„์น˜ ์ž„๋ฒ ๋”ฉ์„ ์›๋ž˜ ์ด๋ฏธ์ง€์—์„œ์˜ ์œ„์น˜์— ๋”ฐ๋ผ 2D ๋ณด๊ฐ„(interpolation)์„ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค. ์ด ๋•Œ, ํ•ด์ƒ๋„ ์กฐ์ •๊ณผ ํŒจ์น˜ ์ถ”์ถœ์€ ์ด๋ฏธ์ง€์˜ 2D ๊ตฌ์กฐ์— ๋Œ€ํ•œ ๊ท€๋‚ฉ์  ํŽธํ–ฅ์ด Vision Transformer์— ์ˆ˜๋™์œผ๋กœ ์ฃผ์ž…๋˜๋Š” ์œ ์ผํ•œ ์ง€์ ์ž„์— ์œ ์˜ํ•ฉ๋‹ˆ๋‹ค.

→ transformer encoder๋Š” ๊ทธ๋Œ€๋กœ ์‚ฌ์šฉํ•˜๋˜, MLP head (MLP์˜ ์ถœ๋ ฅ์„ ์ž…๋ ฅ์œผ๋กœ ๋ฐ›์•„ ์ตœ์ข… ์˜ˆ์ธก๊ฐ’ ๋งŒ๋“œ๋Š” ์—ญํ• )์„ 0์œผ๋กœ ์ดˆ๊ธฐํ™”. (์ดˆ๊ธฐํ™” ๋ฐฉ๋ฒ•์œผ๋กœ ์ƒ๊ฐํ•˜๋ฉด ๋  ๋“ฏ)

โ€ป pre-trained prediction head: ์ด๋ฏธ์ง€ ๋ถ„๋ฅ˜ ์ž‘์—…์—์„œ๋Š” ์˜ˆ์ธก ํ—ค๋“œ๊ฐ€ ํด๋ž˜์Šค ์ˆ˜์— ํ•ด๋‹นํ•˜๋Š” ์ถœ๋ ฅ ๋…ธ๋“œ๋ฅผ ๊ฐ€์ง€๊ณ , ๊ฐ ํด๋ž˜์Šค์— ๋Œ€ํ•œ ํ™•๋ฅ ์„ ์˜ˆ์ธกํ•จ.

→ ViT๋ฅผ fine tuning ํ•  ๋•Œ, pre-training๊ณผ ๋™์ผํ•œ ํŒจ์น˜ ํฌ๊ธฐ๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ๋•Œ๋ฌธ์—, ๊ณ ํ•ด์ƒ๋„ ์ด๋ฏธ์ง€๋กœ fine-tuning์„ ํ•  ๊ฒฝ์šฐ, sequence์˜ ๊ธธ์ด๊ฐ€ ๋” ๊ธธ์–ด์ง.

→ ViT๋Š” ๊ฐ€๋ณ€์  ํŒจ์น˜๋“ค์„ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ์ง€๋งŒ, pre-trained position embedding์€ ์˜๋ฏธ๊ฐ€ ์‚ฌ๋ผ์ง€๊ธฐ ๋•Œ๋ฌธ์—, pretrained position embedding์„ ์›๋ณธ ์ด๋ฏธ์ง€ ์œ„์น˜์— ๋”ฐ๋ผ ์ด์ค‘ ์„ ํ˜•๋ณด๊ฐ„๋ฒ• ์‚ฌ์šฉ

4. Experiments

We evaluate the representation learning capabilities of ResNet, Vision Transformer (ViT), and the hybrid. To understand the data requirements of each model, we pre-train on datasets of varying size and evaluate many benchmark tasks. When considering the computational cost of pre-training the model, ViT performs very favourably, attaining state of the art on most recognition benchmarks at a lower pre-training cost. Lastly, we perform a small experiment using self-supervision, and show that self-supervised ViT holds promise for the future.

์šฐ๋ฆฌ๋Š” ResNet, Vision Transformer (ViT), ๊ทธ๋ฆฌ๊ณ  ํ•˜์ด๋ธŒ๋ฆฌ๋“œ ๋ชจ๋ธ์˜ ํ‘œํ˜„ ํ•™์Šต ๋Šฅ๋ ฅ์„ ํ‰๊ฐ€ํ•ฉ๋‹ˆ๋‹ค. ๊ฐ ๋ชจ๋ธ์˜ ๋ฐ์ดํ„ฐ ์š”๊ตฌ ์‚ฌํ•ญ์„ ์ดํ•ดํ•˜๊ธฐ ์œ„ํ•ด ๋‹ค์–‘ํ•œ ํฌ๊ธฐ์˜ ๋ฐ์ดํ„ฐ์…‹์—์„œ ์‚ฌ์ „ ํ›ˆ๋ จ์„ ์ˆ˜ํ–‰ํ•˜๊ณ  ์—ฌ๋Ÿฌ ๋ฒค์น˜๋งˆํฌ ์ž‘์—…์„ ํ‰๊ฐ€ํ•ฉ๋‹ˆ๋‹ค. ๋ชจ๋ธ์˜ ์‚ฌ์ „ ํ›ˆ๋ จ ๋น„์šฉ์„ ๊ณ ๋ คํ•  ๋•Œ, ViT๋Š” ๋งค์šฐ ์šฐ์ˆ˜ํ•œ ์„ฑ๋Šฅ์„ ๋ณด์—ฌ์ฃผ๋ฉฐ, ๋‚ฎ์€ ์‚ฌ์ „ ํ›ˆ๋ จ ๋น„์šฉ์œผ๋กœ ๋Œ€๋ถ€๋ถ„์˜ ์ธ์‹ ๋ฒค์น˜๋งˆํฌ์—์„œ ์ตœ๊ณ  ์„ฑ๋Šฅ์„ ๋‹ฌ์„ฑํ•ฉ๋‹ˆ๋‹ค. ๋งˆ์ง€๋ง‰์œผ๋กœ, ์šฐ๋ฆฌ๋Š” ์ž๊ธฐ ์ง€๋„ ํ•™์Šต์„ ์‚ฌ์šฉํ•œ ์ž‘์€ ์‹คํ—˜์„ ์ˆ˜ํ–‰ํ•˜๊ณ , ์ž๊ธฐ ์ง€๋„ ํ•™์Šต ViT๊ฐ€ ๋ฏธ๋ž˜์— ๋Œ€ํ•œ ์•ฝ์†์„ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค.

4.1 SETUP Datasets.

To explore model scalability, we use the ILSVRC-2012 ImageNet dataset with 1k classes and 1.3M images (we refer to it as ImageNet in what follows), its superset ImageNet-21k with 21k classes and 14M images (Deng et al., 2009), and JFT (Sun et al., 2017) with 18k classes and 303M high-resolution images. We de-duplicate the pre-training datasets w.r.t. the test sets of the downstream tasks following Kolesnikov et al. (2020). We transfer the models trained on these dataset to several benchmark tasks: ImageNet on the original validation labels and the cleaned-up ReaL labels (Beyer et al., 2020), CIFAR-10/100 (Krizhevsky, 2009), Oxford-IIIT Pets (Parkhi et al., 2012), and Oxford Flowers-102 (Nilsback & Zisserman, 2008). For these datasets, pre-processing follows Kolesnikov et al. (2020). We also evaluate on the 19-task VTAB classification suite (Zhai et al., 2019b). VTAB evaluates low-data transfer to diverse tasks, using 1 000 training examples per task. The tasks are divided into three groups: Natural – tasks like the above, Pets, CIFAR, etc. Specialized – medical and satellite imagery, and Structured – tasks that require geometric understanding like localization.

๋ชจ๋ธ์˜ ํ™•์žฅ์„ฑ์„ ํƒ๊ตฌํ•˜๊ธฐ ์œ„ํ•ด, ์šฐ๋ฆฌ๋Š” ๋‹ค์–‘ํ•œ ๋ฐ์ดํ„ฐ์…‹์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ILSVRC-2012 ImageNet ๋ฐ์ดํ„ฐ์…‹์€ 1,000๊ฐœ ํด๋ž˜์Šค์™€ 1.3๋ฐฑ๋งŒ ์žฅ์˜ ์ด๋ฏธ์ง€๋กœ ๊ตฌ์„ฑ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ImageNet์˜ ์ƒ์œ„ ์ง‘ํ•ฉ์ธ ImageNet-21k๋Š” 21,000๊ฐœ ํด๋ž˜์Šค์™€ 14๋ฐฑ๋งŒ ์žฅ์˜ ์ด๋ฏธ์ง€๋กœ ์ด๋ฃจ์–ด์ ธ ์žˆ์Šต๋‹ˆ๋‹ค. ๋˜ํ•œ, JFT ๋ฐ์ดํ„ฐ์…‹์€ 18,000๊ฐœ ํด๋ž˜์Šค์™€ 3์–ต 3์ฒœ๋งŒ ๊ฐœ์˜ ๊ณ ํ•ด์ƒ๋„ ์ด๋ฏธ์ง€๋กœ ๊ตฌ์„ฑ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.

์‹คํ—˜์˜ ๊ณต์ •์„ฑ์„ ๋ณด์žฅํ•˜๊ธฐ ์œ„ํ•ด, ์šฐ๋ฆฌ๋Š” ์‚ฌ์ „ ํ›ˆ๋ จ ๋ฐ์ดํ„ฐ์…‹๊ณผ ํ›„์† ์ž‘์—…์˜ ํ…Œ์ŠคํŠธ ์„ธํŠธ ์‚ฌ์ด์—์„œ ์ค‘๋ณต๋œ ์ด๋ฏธ์ง€๋ฅผ ์ œ๊ฑฐํ•ฉ๋‹ˆ๋‹ค. ์ด๋Š” Kolesnikov ๋“ฑ์˜ ์ ‘๊ทผ ๋ฐฉ์‹์„ ๋”ฐ๋ฆ…๋‹ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ์ด๋Ÿฌํ•œ ์‚ฌ์ „ ํ›ˆ๋ จ ๋ชจ๋ธ์„ ์—ฌ๋Ÿฌ ๋ฒค์น˜๋งˆํฌ ์ž‘์—…์— ์ „์ดํ•ฉ๋‹ˆ๋‹ค. ๋ฒค์น˜๋งˆํฌ ์ž‘์—…์—๋Š” ImageNet (์›๋ž˜์˜ ๊ฒ€์ฆ ๋ ˆ์ด๋ธ”๊ณผ ์ •์ œ๋œ ReaL ๋ ˆ์ด๋ธ”), CIFAR-10/100, Oxford-IIIT Pets, Oxford Flowers-102๊ฐ€ ํฌํ•จ๋ฉ๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ๋ฐ์ดํ„ฐ์…‹์— ๋Œ€ํ•œ ์‚ฌ์ „ ์ฒ˜๋ฆฌ ๋‹จ๊ณ„๋Š” Kolesnikov ๋“ฑ์˜ ๋ฐฉ๋ฒ•๋ก ์„ ๋”ฐ๋ฆ…๋‹ˆ๋‹ค.

๋˜ํ•œ, VTAB ๋ถ„๋ฅ˜ ์Šค์œ„ํŠธ์—์„œ๋„ ๋ชจ๋ธ์„ ํ‰๊ฐ€ํ•ฉ๋‹ˆ๋‹ค. VTAB๋Š” 19๊ฐœ์˜ ์ž‘์—…์œผ๋กœ ๊ตฌ์„ฑ๋˜์–ด ์žˆ์œผ๋ฉฐ, ๊ฐ ์ž‘์—…์—๋Š” 1,000๊ฐœ์˜ ํ›ˆ๋ จ ์˜ˆ์ œ๋งŒ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. ์ด ์ž‘์—…๋“ค์€ ์„ธ ๊ฐ€์ง€ ๊ทธ๋ฃน์œผ๋กœ ๋‚˜๋‰˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. Natural ๊ทธ๋ฃน์—๋Š” Pets, CIFAR ๋“ฑ๊ณผ ๊ฐ™์€ ์ž‘์—…์ด ํฌํ•จ๋˜์–ด ์žˆ์œผ๋ฉฐ, Specialized ๊ทธ๋ฃน์—๋Š” ์˜๋ฃŒ ๋ฐ ์œ„์„ฑ ์ด๋ฏธ์ง€ ์ž‘์—…์ด ํฌํ•จ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  Structured ๊ทธ๋ฃน์—๋Š” ์ง€์˜ค๋ฉ”ํŠธ๋ฆฌ ์ดํ•ด์™€ ๋กœ์ปฌ๋ผ์ด์ œ์ด์…˜์ด ํ•„์š”ํ•œ ์ž‘์—…์ด ํฌํ•จ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.

Model Variants. We base ViT configurations on those used for BERT (Devlin et al., 2019), as summarized in Table 1. The “Base” and “Large” models are directly adopted from BERT and we add the larger “Huge” model. In what follows we use brief notation to indicate the model size and the input patch size: for instance, ViT-L/16 means the “Large” variant with 16×16 input patch size. Note that the Transformer’s sequence length is inversely proportional to the square of the patch size, thus models with smaller patch size are computationally more expensive. For the baseline CNNs, we use ResNet (He et al., 2016), but replace the Batch Normalization layers (Ioffe & Szegedy, 2015) with Group Normalization (Wu & He, 2018), and used standardized convolutions (Qiao et al., 2019). These modifications improve transfer (Kolesnikov et al., 2020), and we denote the modified model “ResNet (BiT)”. For the hybrids, we feed the intermediate feature maps into ViT with patch size of one “pixel”. To experiment with different sequence lengths, we either (i) take the output of stage 4 of a regular ResNet50 or (ii) remove stage 4, place the same number of layers in stage 3 (keeping the total number of layers), and take the output of this extended stage 3. Option (ii) results in a 4x longer sequence length, and a more expensive ViT model.

ViT ๊ตฌ์„ฑ์€ BERT์— ์‚ฌ์šฉ๋œ ๊ตฌ์„ฑ์„ ๊ธฐ๋ฐ˜์œผ๋กœ ํ•˜๋ฉฐ, ์ด๋Š” Table 1์— ์š”์•ฝ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. "Base"์™€ "Large" ๋ชจ๋ธ์€ BERT์—์„œ ์ง์ ‘ ์ฑ„์šฉ๋˜์—ˆ์œผ๋ฉฐ, ์šฐ๋ฆฌ๋Š” ๋” ํฐ "Huge" ๋ชจ๋ธ์„ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค. ์ดํ›„์—๋Š” ๋ชจ๋ธ ํฌ๊ธฐ์™€ ์ž…๋ ฅ ํŒจ์น˜ ํฌ๊ธฐ๋ฅผ ๊ฐ„๋‹จํ•˜๊ฒŒ ํ‘œ๊ธฐํ•˜์—ฌ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, ViT-L/16์€ 16x16 ์ž…๋ ฅ ํŒจ์น˜ ํฌ๊ธฐ๋ฅผ ๊ฐ€์ง„ "Large" ๋ณ€ํ˜• ๋ชจ๋ธ์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค. ํŒจ์น˜ ํฌ๊ธฐ์˜ ์ œ๊ณฑ์— ๋ฐ˜๋น„๋ก€ํ•˜๋Š” ํŠธ๋žœ์Šคํฌ๋จธ์˜ ์‹œํ€€์Šค ๊ธธ์ด๋ฅผ ์œ ์˜ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ ํŒจ์น˜ ํฌ๊ธฐ๊ฐ€ ์ž‘์€ ๋ชจ๋ธ์ผ์ˆ˜๋ก ๊ณ„์‚ฐ ๋น„์šฉ์ด ๋” ๋งŽ์ด ๋“ญ๋‹ˆ๋‹ค.

๊ธฐ์ค€์ด ๋˜๋Š” CNN์œผ๋กœ๋Š” ResNet (He ๋“ฑ, 2016)์„ ์‚ฌ์šฉํ•˜์ง€๋งŒ, Batch Normalization ๋ ˆ์ด์–ด(Ioffe & Szegedy, 2015)๋ฅผ Group Normalization (Wu & He, 2018)์œผ๋กœ ๋Œ€์ฒดํ•˜๊ณ , ํ‘œ์ค€ํ™”๋œ ํ•ฉ์„ฑ๊ณฑ(Qiao ๋“ฑ, 2019)์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ์ˆ˜์ • ์‚ฌํ•ญ์€ ์ „์ด ํ•™์Šต์„ ๊ฐœ์„ ํ•˜๋ฉฐ, ์ˆ˜์ •๋œ ๋ชจ๋ธ์„ "ResNet (BiT)"๋ผ๊ณ  ํ‘œ๊ธฐํ•ฉ๋‹ˆ๋‹ค. ํ•˜์ด๋ธŒ๋ฆฌ๋“œ ๋ชจ๋ธ์˜ ๊ฒฝ์šฐ ์ค‘๊ฐ„ ํŠน์„ฑ ๋งต์„ ํ•œ ๊ฐœ์˜ "ํ”ฝ์…€" ํฌ๊ธฐ์˜ ํŒจ์น˜๋กœ ViT์— ์ „๋‹ฌํ•ฉ๋‹ˆ๋‹ค. ๋‹ค๋ฅธ ์‹œํ€€์Šค ๊ธธ์ด๋ฅผ ์‹คํ—˜ํ•˜๊ธฐ ์œ„ํ•ด, (i) ์ผ๋ฐ˜์ ์ธ ResNet50์˜ stage 4์˜ ์ถœ๋ ฅ์„ ์‚ฌ์šฉํ•˜๊ฑฐ๋‚˜ (ii) stage 4๋ฅผ ์ œ๊ฑฐํ•˜๊ณ  ๋™์ผํ•œ ์ˆ˜์˜ ๋ ˆ์ด์–ด๋ฅผ stage 3์— ๋ฐฐ์น˜ํ•˜๊ณ  ์ด ํ™•์žฅ๋œ stage 3์˜ ์ถœ๋ ฅ์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. (ii) ์˜ต์…˜์€ 4๋ฐฐ ๋” ๊ธด ์‹œํ€€์Šค ๊ธธ์ด์™€ ๋” ๋น„์‹ผ ViT ๋ชจ๋ธ์„ ๋งŒ๋“ค์–ด๋ƒ…๋‹ˆ๋‹ค.

Training & Fine-tuning. We train all models, including ResNets, using Adam (Kingma & Ba, 2015) with β1 = 0.9, β2 = 0.999, a batch size of 4096 and apply a high weight decay of 0.1, which we found to be useful for transfer of all models (Appendix D.1 shows that, in contrast to common practices, Adam works slightly better than SGD for ResNets in our setting). We use a linear learning rate warmup and decay, see Appendix B.1 for details. For fine-tuning we use SGD with momentum, batch size 512, for all models, see Appendix B.1.1. For ImageNet results in Table 2, we fine-tuned at higher resolution: 512 for ViT-L/16 and 518 for ViT-H/14, and also used Polyak & Juditsky (1992) averaging with a factor of 0.9999 (Ramachandran et al., 2019; Wang et al., 2020b).

ํ›ˆ๋ จ ๋ฐ ํŒŒ์ธํŠœ๋‹. ์šฐ๋ฆฌ๋Š” ResNet์„ ํฌํ•จํ•œ ๋ชจ๋“  ๋ชจ๋ธ์„ Adam (Kingma & Ba, 2015)์„ ์‚ฌ์šฉํ•˜์—ฌ ํ›ˆ๋ จํ•ฉ๋‹ˆ๋‹ค. ์ด๋•Œ β1 = 0.9, β2 = 0.999, ๋ฐฐ์น˜ ํฌ๊ธฐ๋Š” 4096์ด๋ฉฐ, ๊ฐ€์ค‘์น˜ ๊ฐ์‡ (weight decay)๋กœ๋Š” 0.1์„ ์ ์šฉํ•ฉ๋‹ˆ๋‹ค. ์ด๋Š” ๋ชจ๋“  ๋ชจ๋ธ์˜ ์ „์ด ํ•™์Šต์— ์œ ์šฉํ•˜๋‹ค๋Š” ๊ฒƒ์„ ๋ฐœ๊ฒฌํ•˜์˜€์Šต๋‹ˆ๋‹ค (๋ถ€๋ก D.1์—์„œ๋Š” ์ผ๋ฐ˜์ ์ธ ๊ด€ํ–‰๊ณผ๋Š” ๋‹ค๋ฅด๊ฒŒ, Adam์ด ์šฐ๋ฆฌ์˜ ์„ค์ •์—์„œ ResNet์— ๋Œ€ํ•ด SGD๋ณด๋‹ค ์•ฝ๊ฐ„ ๋” ์ž˜ ์ž‘๋™ํ•œ๋‹ค๋Š” ๊ฒƒ์„ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค). ์„ ํ˜• ํ•™์Šต๋ฅ  ์›œ์—…๊ณผ ๊ฐ์†Œ๋ฅผ ์‚ฌ์šฉํ•˜๋ฉฐ, ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๋ถ€๋ก B.1์„ ์ฐธ์กฐํ•˜์‹ญ์‹œ์˜ค. ํŒŒ์ธํŠœ๋‹์—๋Š” SGD์™€ ๋ชจ๋ฉ˜ํ…€์„ ์‚ฌ์šฉํ•˜๋ฉฐ, ๋ชจ๋“  ๋ชจ๋ธ์— ๋Œ€ํ•ด ๋ฐฐ์น˜ ํฌ๊ธฐ๋Š” 512๋กœ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค. ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๋ถ€๋ก B.1.1์„ ์ฐธ์กฐํ•˜์‹ญ์‹œ์˜ค. Table 2์˜ ImageNet ๊ฒฐ๊ณผ์—์„œ๋Š” ๋” ๋†’์€ ํ•ด์ƒ๋„์—์„œ ํŒŒ์ธํŠœ๋‹์„ ์ง„ํ–‰ํ•˜์˜€์Šต๋‹ˆ๋‹ค. ViT-L/16์˜ ๊ฒฝ์šฐ 512, ViT-H/14์˜ ๊ฒฝ์šฐ 518๋กœ ์„ค์ •ํ•˜์˜€์œผ๋ฉฐ, Polyak & Juditsky (1992) ํ‰๊ท ํ™”๋ฅผ 0.9999์˜ ๋น„์œจ๋กœ ์‚ฌ์šฉํ•˜์˜€์Šต๋‹ˆ๋‹ค (Ramachandran et al., 2019; Wang et al., 2020b).

Metrics. We report results on downstream datasets either through few-shot or fine-tuning accuracy. Fine-tuning accuracies capture the performance of each model after fine-tuning it on the respective dataset. Few-shot accuracies are obtained by solving a regularized least-squares regression problem that maps the (frozen) representation of a subset of training images to {−1, 1} K target vectors. This formulation allows us to recover the exact solution in closed form. Though we mainly focus on fine-tuning performance, we sometimes use linear few-shot accuracies for fast on-the-fly evaluation where fine-tuning would be too costly.

์šฐ๋ฆฌ๋Š” ๋‹ค์šด์ŠคํŠธ๋ฆผ ๋ฐ์ดํ„ฐ์…‹์— ๋Œ€ํ•œ ๊ฒฐ๊ณผ๋ฅผ ํ‘œ์‹œํ•  ๋•Œ ์ ์€ ๋ฐ์ดํ„ฐ์…‹(few-shot) ๋˜๋Š” ํŒŒ์ธํŠœ๋‹ ์ •ํ™•๋„๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ํŒŒ์ธํŠœ๋‹ ์ •ํ™•๋„๋Š” ๊ฐ ๋ชจ๋ธ์„ ํ•ด๋‹น ๋ฐ์ดํ„ฐ์…‹์— ํŒŒ์ธํŠœ๋‹ํ•œ ํ›„์˜ ์„ฑ๋Šฅ์„ ์ธก์ •ํ•ฉ๋‹ˆ๋‹ค. ์ ์€ ๋ฐ์ดํ„ฐ์…‹ ์ •ํ™•๋„๋Š” (๊ณ ์ •๋œ) ์ผ๋ถ€ ํ›ˆ๋ จ ์ด๋ฏธ์ง€์˜ ํ‘œํ˜„์„ {−1, 1} K์˜ ๋ชฉํ‘œ ๋ฒกํ„ฐ์— ๋งคํ•‘ํ•˜๋Š” ์ •๊ทœํ™”๋œ ์ตœ์†Œ์ œ๊ณฑ ํšŒ๊ท€ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜์—ฌ ์–ป์Šต๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ์ˆ˜์‹์€ ๋‹ซํžŒ ํ˜•ํƒœ๋กœ ์ •ํ™•ํ•œ ์†”๋ฃจ์…˜์„ ๋ณต๊ตฌํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•ฉ๋‹ˆ๋‹ค. ์šฐ๋ฆฌ๋Š” ์ฃผ๋กœ ํŒŒ์ธํŠœ๋‹ ์„ฑ๋Šฅ์— ์ดˆ์ ์„ ๋‘์ง€๋งŒ, ํŒŒ์ธํŠœ๋‹์ด ๋„ˆ๋ฌด ๋น„์šฉ์ด ๋งŽ์ด ๋“œ๋Š” ๊ฒฝ์šฐ์—๋Š” ์„ ํ˜•์ ์ธ ์ ์€ ๋ฐ์ดํ„ฐ์…‹ ์ •ํ™•๋„๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋น ๋ฅด๊ฒŒ ์‹ค์‹œ๊ฐ„์œผ๋กœ ํ‰๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

4.2 COMPARISON TO STATE OF THE ART We first compare our largest models – ViT-H/14 and ViT-L/16 – to state-of-the-art CNNs from the literature. The first comparison point is Big Transfer (BiT) (Kolesnikov et al., 2020), which performs supervised transfer learning with large ResNets. The second is Noisy Student (Xie et al., 2020), which is a large EfficientNet trained using semi-supervised learning on ImageNet and JFT300M with the labels removed. Currently, Noisy Student is the state of the art on ImageNet and BiT-L on the other datasets reported here. All models were trained on TPUv3 hardware, and we report the number of TPUv3-core-days taken to pre-train each of them, that is, the number of TPU v3 cores (2 per chip) used for training multiplied by the training time in days. Table 2 shows the results. The smaller ViT-L/16 model pre-trained on JFT-300M outperforms BiT-L (which is pre-trained on the same dataset) on all tasks, while requiring substantially less computational resources to train. The larger model, ViT-H/14, further improves the performance, especially on the more challenging datasets – ImageNet, CIFAR-100, and the VTAB suite. Interestingly, this model still took substantially less compute to pre-train than prior state of the art. However, we note that pre-training efficiency may be affected not only by the architecture choice, but also other parameters, such as training schedule, optimizer, weight decay, etc. We provide a controlled study of performance vs. compute for different architectures in Section 4.4. Finally, the ViT-L/16 model pre-trained on the public ImageNet-21k dataset performs well on most datasets too, while taking fewer resources to pre-train: it could be trained using a standard cloud TPUv3 with 8 cores in approximately 30 days.

4.2 ์ตœ์‹  ๊ธฐ์ˆ ๊ณผ์˜ ๋น„๊ต ์šฐ์„  ๊ฐ€์žฅ ํฐ ๋ชจ๋ธ์ธ ViT-H/14์™€ ViT-L/16์„ ๋ฌธํ—Œ์—์„œ ์ œ์‹œ๋œ ์ตœ์‹  CNN๊ณผ ๋น„๊ตํ•ฉ๋‹ˆ๋‹ค. ์ฒซ ๋ฒˆ์งธ ๋น„๊ต ๋Œ€์ƒ์€ Big Transfer (BiT) (Kolesnikov et al., 2020)์ž…๋‹ˆ๋‹ค. BiT๋Š” ํฐ ResNet์„ ์‚ฌ์šฉํ•œ ์ง€๋„ ์ „์ด ํ•™์Šต์„ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค. ๋‘ ๋ฒˆ์งธ๋Š” Noisy Student (Xie et al., 2020)๋กœ, ์ด๋Š” ImageNet ๋ฐ JFT300M์—์„œ ๋ผ๋ฒจ์„ ์ œ๊ฑฐํ•œ ์ƒํƒœ๋กœ ์ค€์ง€๋„ ํ•™์Šต์„ ์ˆ˜ํ–‰ํ•˜๋Š” ํฐ EfficientNet์ž…๋‹ˆ๋‹ค. ํ˜„์žฌ, Noisy Student๋Š” ImageNet์—์„œ ์ตœ์‹  ๊ธฐ์ˆ ์ด๋ฉฐ, ๋‹ค๋ฅธ ๋ฐ์ดํ„ฐ์…‹์—์„œ๋Š” BiT-L์ด ์ตœ์‹  ๊ธฐ์ˆ ์ž…๋‹ˆ๋‹ค. ๋ชจ๋“  ๋ชจ๋ธ์€ TPUv3 ํ•˜๋“œ์›จ์–ด์—์„œ ํ›ˆ๋ จ๋˜์—ˆ์œผ๋ฉฐ, ๊ฐ๊ฐ์˜ ์‚ฌ์ „ ํ›ˆ๋ จ์— ์†Œ์š”๋œ TPUv3 ์ฝ”์–ด-์ผ ์ˆ˜๋ฅผ ๋ณด๊ณ ํ•ฉ๋‹ˆ๋‹ค. ์ด๋Š” ํ›ˆ๋ จ์— ์‚ฌ์šฉ๋œ TPU v3 ์ฝ”์–ด(์นฉ๋‹น 2๊ฐœ)์˜ ๊ฐœ์ˆ˜๋ฅผ ํ›ˆ๋ จ ๊ธฐ๊ฐ„(์ผ)์œผ๋กœ ๊ณฑํ•œ ๊ฐ’์ž…๋‹ˆ๋‹ค. Table 2๋Š” ์ด๋Ÿฌํ•œ ๊ฒฐ๊ณผ๋ฅผ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค. JFT-300M์—์„œ ์‚ฌ์ „ ํ›ˆ๋ จ๋œ ์ž‘์€ ViT-L/16 ๋ชจ๋ธ์€ ๋ชจ๋“  ์ž‘์—…์—์„œ ๋™์ผํ•œ ๋ฐ์ดํ„ฐ์…‹์—์„œ ์‚ฌ์ „ ํ›ˆ๋ จ๋œ BiT-L๋ณด๋‹ค ์šฐ์ˆ˜ํ•œ ์„ฑ๋Šฅ์„ ๋ฐœํœ˜ํ•˜๋ฉฐ, ํ›ˆ๋ จ์— ํ•„์š”ํ•œ ๊ณ„์‚ฐ ์ž์›์€ ํ›จ์”ฌ ์ ์Šต๋‹ˆ๋‹ค. ๋” ํฐ ๋ชจ๋ธ์ธ ViT-H/14์€ ํŠนํžˆ ImageNet, CIFAR-100 ๋ฐ VTAB ์Šค์œ„ํŠธ์™€ ๊ฐ™์€ ๋” ๋„์ „์ ์ธ ๋ฐ์ดํ„ฐ์…‹์—์„œ ์„ฑ๋Šฅ์„ ๋”์šฑ ํ–ฅ์ƒ์‹œํ‚ต๋‹ˆ๋‹ค. ํฅ๋ฏธ๋กญ๊ฒŒ๋„, ์ด ๋ชจ๋ธ์€ ์—ฌ์ „ํžˆ ์‚ฌ์ „ ํ›ˆ๋ จ์— ์ด์ „์˜ ์ตœ์‹  ๊ธฐ์ˆ ๋ณด๋‹ค ํ›จ์”ฌ ์ ์€ ๊ณ„์‚ฐ ๋ฆฌ์†Œ์Šค๋ฅผ ์‚ฌ์šฉํ–ˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ ์‚ฌ์ „ ํ›ˆ๋ จ ํšจ์œจ์„ฑ์€ ์•„ํ‚คํ…์ฒ˜ ์„ ํƒ๋ฟ๋งŒ ์•„๋‹ˆ๋ผ ํ›ˆ๋ จ ์ผ์ •, ์˜ตํ‹ฐ๋งˆ์ด์ €, ๊ฐ€์ค‘์น˜ ๊ฐ์‡  ๋“ฑ ๋‹ค๋ฅธ ๋งค๊ฐœ๋ณ€์ˆ˜์—๋„ ์˜ํ–ฅ์„ ๋ฐ›์„ ์ˆ˜ ์žˆ์Œ์„ ์ฐธ๊ณ ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์„œ๋กœ ๋‹ค๋ฅธ ์•„ํ‚คํ…์ฒ˜์— ๋Œ€ํ•œ ์„ฑ๋Šฅ ๋Œ€ ๊ณ„์‚ฐ ๋น„๊ต์— ๋Œ€ํ•œ ์ œ์–ด๋œ ์—ฐ๊ตฌ๋ฅผ 4.4์ ˆ์—์„œ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ๋งˆ์ง€๋ง‰์œผ๋กœ, ๊ณต๊ฐœ๋œ ImageNet-21k ๋ฐ์ดํ„ฐ์…‹์—์„œ ์‚ฌ์ „ ํ›ˆ๋ จ๋œ ViT-L/16 ๋ชจ๋ธ์€ ๋Œ€๋ถ€๋ถ„์˜ ๋ฐ์ดํ„ฐ์…‹์—์„œ๋„ ์ž˜ ์ˆ˜ํ–‰๋˜๋ฉฐ, ์‚ฌ์ „ ํ›ˆ๋ จ์— ํ•„์š”ํ•œ ์ž์›์€ ์ ์Šต๋‹ˆ๋‹ค. ์ผ๋ฐ˜์ ์ธ ํด๋ผ์šฐ๋“œ TPUv3 (8๊ฐœ ์ฝ”์–ด)๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์•ฝ 30์ผ ๋™์•ˆ ํ›ˆ๋ จํ•  ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.

Figure 2 decomposes the VTAB tasks into their respective groups, and compares to previous SOTA methods on this benchmark: BiT, VIVI – a ResNet co-trained on ImageNet and Youtube (Tschannen et al., 2020), and S4L – supervised plus semi-supervised learning on ImageNet (Zhai et al., 2019a). ViT-H/14 outperforms BiT-R152x4, and other methods, on the Natural and Structured tasks. On the Specialized the performance of the top two models is similar.

Figure 2 ๋ถ„ํ•ด VTAB ์ž‘์—…์„ ํ•ด๋‹น ๊ทธ๋ฃน์œผ๋กœ ๋‚˜๋ˆ„๊ณ  ์ด ๋ฒค์น˜๋งˆํฌ์— ๋Œ€ํ•œ ์ด์ „ SOTA ๋ฐฉ๋ฒ•๊ณผ ๋น„๊ตํ•ฉ๋‹ˆ๋‹ค: BiT, VIVI - ImageNet๊ณผ Youtube์—์„œ ๊ณต๋™์œผ๋กœ ํ›ˆ๋ จ๋œ ResNet (Tschannen et al., 2020) ๋ฐ S4L - ImageNet์—์„œ ์ง€๋„ ๋ฐ ์ค€์ง€๋„ ํ•™์Šต (Zhai et al., 2019a). ViT-H/14๋Š” BiT-R152x4 ๋ฐ ๋‹ค๋ฅธ ๋ฐฉ๋ฒ•๋“ค์— ๋น„ํ•ด Natural ๋ฐ Structured ์ž‘์—…์—์„œ ์šฐ์ˆ˜ํ•œ ์„ฑ๋Šฅ์„ ๋ณด์ž…๋‹ˆ๋‹ค. Specialized ์ž‘์—…์—์„œ ์ƒ์œ„ ๋‘ ๋ชจ๋ธ์˜ ์„ฑ๋Šฅ์€ ์œ ์‚ฌํ•ฉ๋‹ˆ๋‹ค.

4.3 PRE-TRAINING DATA REQUIREMENTS The Vision Transformer performs well when pre-trained on a large JFT-300M dataset. With fewer inductive biases for vision than ResNets, how crucial is the dataset size? We perform two series of experiments. First, we pre-train ViT models on datasets of increasing size: ImageNet, ImageNet-21k, and JFT300M. To boost the performance on the smaller datasets, we optimize three basic regularization parameters – weight decay, dropout, and label smoothing. Figure 3 shows the results after finetuning to ImageNet (results on other datasets are shown in Table 5)2 . When pre-trained on the smallest dataset, ImageNet, ViT-Large models underperform compared to ViT-Base models, despite (moderate) regularization. With ImageNet-21k pre-training, their performances are similar. Only with JFT-300M, do we see the full benefit of larger models. Figure 3 also shows the performance region spanned by BiT models of different sizes. The BiT CNNs outperform ViT on ImageNet, but with the larger datasets, ViT overtakes. Second, we train our models on random subsets of 9M, 30M, and 90M as well as the full JFT300M dataset. We do not perform additional regularization on the smaller subsets and use the same hyper-parameters for all settings. This way, we assess the intrinsic model properties, and not the effect of regularization. We do, however, use early-stopping, and report the best validation accuracy achieved during training. To save compute, we report few-shot linear accuracy instead of full finetuning accuracy. Figure 4 contains the results. Vision Transformers overfit more than ResNets with comparable computational cost on smaller datasets. For example, ViT-B/32 is slightly faster than ResNet50; it performs much worse on the 9M subset, but better on 90M+ subsets. The same is true for ResNet152x2 and ViT-L/16. This result reinforces the intuition that the convolutional inductive bias is useful for smaller datasets, but for larger ones, learning the relevant patterns directly from data is sufficient, even beneficial. Overall, the few-shot results on ImageNet (Figure 4), as well as the low-data results on VTAB (Table 2) seem promising for very low-data transfer. Further analysis of few-shot properties of ViT is an exciting direction of future work.

๋น„์ „ ํŠธ๋žœ์Šคํฌ๋จธ(Vision Transformer)๋Š” ๋Œ€์šฉ๋Ÿ‰ JFT-300M ๋ฐ์ดํ„ฐ์…‹์œผ๋กœ ์‚ฌ์ „ ํ•™์Šต ์‹œ ์šฐ์ˆ˜ํ•œ ์„ฑ๋Šฅ์„ ๋ณด์ž…๋‹ˆ๋‹ค. ResNet๊ณผ ๋น„๊ตํ•˜์—ฌ ๋น„์ „์— ๋Œ€ํ•œ ๊ท€๋‚ฉ์  ํŽธํ–ฅ์ด ์ ์€ ํŠธ๋žœ์Šคํฌ๋จธ ๋ชจ๋ธ์—์„œ ๋ฐ์ดํ„ฐ์…‹์˜ ํฌ๊ธฐ๋Š” ์–ผ๋งˆ๋‚˜ ์ค‘์š”ํ•œ์ง€ ์•Œ์•„๋ณด๊ธฐ ์œ„ํ•ด ๋‘ ๊ฐ€์ง€ ์‹คํ—˜์„ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค.

์ฒซ ๋ฒˆ์งธ๋กœ, ViT ๋ชจ๋ธ์„ ImageNet, ImageNet-21k ๋ฐ JFT300M๊ณผ ๊ฐ™์€ ํฌ๊ธฐ์˜ ๋ฐ์ดํ„ฐ์…‹์—์„œ ์‚ฌ์ „ ํ•™์Šตํ•ฉ๋‹ˆ๋‹ค. ์ž‘์€ ๋ฐ์ดํ„ฐ์…‹์—์„œ์˜ ์„ฑ๋Šฅ์„ ํ–ฅ์ƒ์‹œํ‚ค๊ธฐ ์œ„ํ•ด ๊ฐ€์ค‘์น˜ ๊ฐ์†Œ(weight decay), ๋“œ๋กญ์•„์›ƒ(dropout), ๋ผ๋ฒจ ์Šค๋ฌด๋”ฉ(label smoothing)๊ณผ ๊ฐ™์€ ์„ธ ๊ฐ€์ง€ ๊ธฐ๋ณธ์ ์ธ ์ •๊ทœํ™” ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ์ตœ์ ํ™”ํ•ฉ๋‹ˆ๋‹ค. Figure 3์€ ImageNet์œผ๋กœ์˜ ํŒŒ์ธํŠœ๋‹ ์ดํ›„์˜ ๊ฒฐ๊ณผ๋ฅผ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค(๋‹ค๋ฅธ ๋ฐ์ดํ„ฐ์…‹์˜ ๊ฒฐ๊ณผ๋Š” ํ…Œ์ด๋ธ” 5์— ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค). ๊ฐ€์žฅ ์ž‘์€ ๋ฐ์ดํ„ฐ์…‹์ธ ImageNet์œผ๋กœ ์‚ฌ์ „ ํ•™์Šตํ•  ๋•Œ, ViT-Large ๋ชจ๋ธ์€ (์ ๋‹นํ•œ ์ •๊ทœํ™”์—๋„ ๋ถˆ๊ตฌํ•˜๊ณ ) ViT-Base ๋ชจ๋ธ๋ณด๋‹ค ์„ฑ๋Šฅ์ด ๋–จ์–ด์ง‘๋‹ˆ๋‹ค. ImageNet-21k ์‚ฌ์ „ ํ•™์Šต ์‹œ ๋‘ ๋ชจ๋ธ์˜ ์„ฑ๋Šฅ์ด ์œ ์‚ฌํ•ด์ง‘๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ JFT-300M ์‚ฌ์ „ ํ•™์Šต ์‹œ์—๋งŒ ํฐ ๋ชจ๋ธ์˜ ๋ชจ๋“  ์ด์ ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. Figure 3์€ ๋‹ค์–‘ํ•œ ํฌ๊ธฐ์˜ BiT ๋ชจ๋ธ์— ๋Œ€ํ•œ ์„ฑ๋Šฅ ๋ฒ”์œ„๋„ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค. BiT CNN์€ ImageNet์—์„œ ViT๋ณด๋‹ค ์šฐ์ˆ˜ํ•œ ์„ฑ๋Šฅ์„ ๋ณด์ž…๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ ๋ฐ์ดํ„ฐ์…‹์˜ ํฌ๊ธฐ๊ฐ€ ์ปค์งˆ์ˆ˜๋ก ViT๊ฐ€ BiT ๋ชจ๋ธ์„ ์•ž์ง€๋ฅผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๋‘ ๋ฒˆ์งธ๋กœ, 9M, 30M, 90M ๋ฐ JFT300M์˜ ๋ฌด์ž‘์œ„ ํ•˜์œ„ ๋ฐ์ดํ„ฐ์…‹์—์„œ ๋ชจ๋ธ์„ ํ›ˆ๋ จํ•ฉ๋‹ˆ๋‹ค. ์ž‘์€ ํ•˜์œ„ ๋ฐ์ดํ„ฐ์…‹์— ๋Œ€ํ•ด์„œ๋Š” ์ถ”๊ฐ€์ ์ธ ์ •๊ทœํ™”๋ฅผ ์ˆ˜ํ–‰ํ•˜์ง€ ์•Š์œผ๋ฉฐ, ๋ชจ๋“  ์„ค์ •์— ๋™์ผํ•œ ํ•˜์ดํผํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ์ด๋ ‡๊ฒŒ ํ•จ์œผ๋กœ์จ ๋ชจ๋ธ์˜ ๋ณธ์งˆ์ ์ธ ํŠน์„ฑ์„ ํ‰๊ฐ€ํ•˜๊ณ , ์ •๊ทœํ™”์˜ ์˜ํ–ฅ์ด ์•„๋‹Œ ๋ชจ๋ธ์˜ ํŠน์„ฑ์„ ์•Œ์•„๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ํ›ˆ๋ จ ์ค‘์— ์ตœ์ƒ์˜ ๊ฒ€์ฆ ์ •ํ™•๋„๋ฅผ ๊ธฐ๋กํ•˜๊ธฐ ์œ„ํ•ด ์กฐ๊ธฐ ์ข…๋ฃŒ๋ฅผ ์‚ฌ์šฉํ•˜๋ฉฐ, ๊ณ„์‚ฐ๋Ÿ‰์„ ์ค„์ด๊ธฐ ์œ„ํ•ด ์™„์ „ํ•œ ํŒŒ์ธํŠœ๋‹ ์ •ํ™•๋„ ๋Œ€์‹  few-shot ์„ ํ˜• ์ •ํ™•๋„๋ฅผ ๋ณด๊ณ ํ•ฉ๋‹ˆ๋‹ค. Figure 4๋Š” ์ด๋Ÿฌํ•œ ๊ฒฐ๊ณผ๋ฅผ ๋‹ด๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ๋น„์ „ ํŠธ๋žœ์Šคํฌ๋จธ๋Š” ๋น„์Šทํ•œ ๊ณ„์‚ฐ ๋น„์šฉ์„ ๊ฐ–๋Š” ResNet๊ณผ ๋น„๊ตํ•˜์—ฌ ์ž‘์€ ๋ฐ์ดํ„ฐ์…‹์—์„œ ๊ณผ์ ํ•ฉ ํ˜„์ƒ์ด ๋” ๋งŽ์ด ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, ViT-B/32๋Š” ResNet50๋ณด๋‹ค ์•ฝ๊ฐ„ ๋” ๋น ๋ฅด์ง€๋งŒ 9M ํ•˜์œ„ ๋ฐ์ดํ„ฐ์…‹์—์„œ ์„ฑ๋Šฅ์ด ํฌ๊ฒŒ ์ €ํ•˜๋˜๊ณ  90M ์ด์ƒ์˜ ํ•˜์œ„ ๋ฐ์ดํ„ฐ์…‹์—์„œ๋Š” ๋” ์ข‹์€ ์„ฑ๋Šฅ์„ ๋ณด์ž…๋‹ˆ๋‹ค. ResNet152x2์™€ ViT-L/16์— ๋Œ€ํ•ด์„œ๋„ ๋™์ผํ•œ ๊ฒฝํ–ฅ์ด ๋‚˜ํƒ€๋‚ฉ๋‹ˆ๋‹ค. ์ด ๊ฒฐ๊ณผ๋Š” ํ•ฉ์„ฑ๊ณฑ์  ํŽธํ–ฅ์ด ์ž‘์€ ๋ฐ์ดํ„ฐ์…‹์— ์œ ์šฉํ•˜์ง€๋งŒ, ํฐ ๋ฐ์ดํ„ฐ์…‹์— ๋Œ€ํ•ด์„œ๋Š” ๋ฐ์ดํ„ฐ๋กœ๋ถ€ํ„ฐ ์ง์ ‘ ๊ด€๋ จ ํŒจํ„ด์„ ํ•™์Šตํ•˜๋Š” ๊ฒƒ์ด ์ถฉ๋ถ„ํ•˜๋ฉฐ ์‹ฌ์ง€์–ด ์ด์ ์ด ์žˆ๋‹ค๋Š” ์ง๊ด€์„ ๊ฐ•ํ™”์‹œํ‚ต๋‹ˆ๋‹ค.

Overall, the few-shot results on ImageNet (Figure 4), as well as the low-data results on VTAB (Table 2) seem promising for very low-data transfer. Further analysis of few-shot properties of ViT is an exciting direction of future work.

์ „๋ฐ˜์ ์œผ๋กœ, ImageNet์—์„œ์˜ ์†Œ์ˆ˜์ƒท ๊ฒฐ๊ณผ (Figure 4) ๋ฐ VTAB์—์„œ์˜ ์ €๋Ÿ‰ ๋ฐ์ดํ„ฐ ๊ฒฐ๊ณผ (Table 2)๋Š” ๋งค์šฐ ์ ์€ ๋ฐ์ดํ„ฐ ์ „์ด์— ๋Œ€ํ•œ ์œ ๋งํ•œ ๊ฐ€๋Šฅ์„ฑ์„ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค. ViT์˜ ์†Œ์ˆ˜์ƒท ํŠน์„ฑ์— ๋Œ€ํ•œ ์ถ”๊ฐ€์ ์ธ ๋ถ„์„์€ ํ–ฅํ›„ ์—ฐ๊ตฌ์˜ ํฅ๋ฏธ๋กœ์šด ๋ฐฉํ–ฅ์ž…๋‹ˆ๋‹ค.

4.4 SCALING STUDY We perform a controlled scaling study of different models by evaluating transfer performance from JFT-300M. In this setting data size does not bottleneck the models’ performances, and we assess performance versus pre-training cost of each model. The model set includes: 7 ResNets, R50x1, R50x2 R101x1, R152x1, R152x2, pre-trained for 7 epochs, plus R152x2 and R200x3 pre-trained for 14 epochs; 6 Vision Transformers, ViT-B/32, B/16, L/32, L/16, pre-trained for 7 epochs, plus L/16 and H/14 pre-trained for 14 epochs; and 5 hybrids, R50+ViT-B/32, B/16, L/32, L/16 pretrained for 7 epochs, plus R50+ViT-L/16 pre-trained for 14 epochs (for hybrids, the number at the end of the model name stands not for the patch size, but for the total dowsampling ratio in the ResNet backbone). Figure 5 contains the transfer performance versus total pre-training compute (see Appendix D.5 for details on computational costs). Detailed results per model are provided in Table 6 in the Appendix. A few patterns can be observed. First, Vision Transformers dominate ResNets on the performance/compute trade-off. ViT uses approximately 2 − 4× less compute to attain the same performance (average over 5 datasets). Second, hybrids slightly outperform ViT at small computational budgets, but the difference vanishes for larger models. This result is somewhat surprising, since one might expect convolutional local feature processing to assist ViT at any size. Third, Vision Transformers appear not to saturate within the range tried, motivating future scaling efforts.

4.4 ์Šค์ผ€์ผ๋ง ์—ฐ๊ตฌ ์šฐ๋ฆฌ๋Š” JFT-300M์œผ๋กœ๋ถ€ํ„ฐ์˜ ์ „์ด ์„ฑ๋Šฅ์„ ํ‰๊ฐ€ํ•˜์—ฌ ๋‹ค์–‘ํ•œ ๋ชจ๋ธ์˜ ์ œ์–ด๋œ ์Šค์ผ€์ผ๋ง ์—ฐ๊ตฌ๋ฅผ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค. ์ด ์„ค์ •์—์„œ๋Š” ๋ฐ์ดํ„ฐ ํฌ๊ธฐ๊ฐ€ ๋ชจ๋ธ์˜ ์„ฑ๋Šฅ์— ์˜ํ–ฅ์„ ๋ฏธ์น˜์ง€ ์•Š์œผ๋ฉฐ, ๊ฐ ๋ชจ๋ธ์˜ ์‚ฌ์ „ ํ›ˆ๋ จ ๋น„์šฉ ๋Œ€๋น„ ์„ฑ๋Šฅ์„ ํ‰๊ฐ€ํ•ฉ๋‹ˆ๋‹ค. ๋ชจ๋ธ ์„ธํŠธ์—๋Š” ๋‹ค์Œ์ด ํฌํ•จ๋ฉ๋‹ˆ๋‹ค. 7๊ฐœ์˜ ResNet ๋ชจ๋ธ์ธ R50x1, R50x2, R101x1, R152x1, R152x2, ๊ฐ๊ฐ 7๊ฐœ์˜ epoch์— ๋Œ€ํ•ด ์‚ฌ์ „ ํ›ˆ๋ จ๋œ ๋ชจ๋ธ๊ณผ R152x2์™€ R200x3๋Š” 14๊ฐœ์˜ epoch์— ๋Œ€ํ•ด ์‚ฌ์ „ ํ›ˆ๋ จ๋œ ๋ชจ๋ธ; 6๊ฐœ์˜ Vision Transformer ๋ชจ๋ธ์ธ ViT-B/32, B/16, L/32, L/16, ๊ฐ๊ฐ 7๊ฐœ์˜ epoch์— ๋Œ€ํ•ด ์‚ฌ์ „ ํ›ˆ๋ จ๋œ ๋ชจ๋ธ๊ณผ L/16 ๋ฐ H/14๋Š” 14๊ฐœ์˜ epoch์— ๋Œ€ํ•ด ์‚ฌ์ „ ํ›ˆ๋ จ๋œ ๋ชจ๋ธ; ๊ทธ๋ฆฌ๊ณ  5๊ฐœ์˜ ํ•˜์ด๋ธŒ๋ฆฌ๋“œ ๋ชจ๋ธ์ธ R50+ViT-B/32, B/16, L/32, L/16์€ ๊ฐ๊ฐ 7๊ฐœ์˜ epoch์— ๋Œ€ํ•ด ์‚ฌ์ „ ํ›ˆ๋ จ๋œ ๋ชจ๋ธ๊ณผ R50+ViT-L/16์€ 14๊ฐœ์˜ epoch์— ๋Œ€ํ•ด ์‚ฌ์ „ ํ›ˆ๋ จ๋œ ๋ชจ๋ธ์ž…๋‹ˆ๋‹ค (ํ•˜์ด๋ธŒ๋ฆฌ๋“œ ๋ชจ๋ธ์˜ ๊ฒฝ์šฐ ๋ชจ๋ธ ์ด๋ฆ„ ๋์˜ ์ˆซ์ž๋Š” ํŒจ์น˜ ํฌ๊ธฐ๊ฐ€ ์•„๋‹Œ ResNet ๋ฐฑ๋ณธ์˜ ์ „์ฒด ๋‹ค์šด์ƒ˜ํ”Œ๋ง ๋น„์œจ์„ ๋‚˜ํƒ€๋ƒ…๋‹ˆ๋‹ค).

Figure 5์—๋Š” ์ „์ด ์„ฑ๋Šฅ ๋Œ€๋น„ ์ด ์‚ฌ์ „ ํ›ˆ๋ จ ์ปดํ“จํŠธ(์ปดํ“จํŒ… ๋น„์šฉ์— ๋Œ€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๋ถ€๋ก D.5๋ฅผ ์ฐธ์กฐ)๊ฐ€ ํฌํ•จ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ๋ชจ๋ธ๋ณ„ ์ž์„ธํ•œ ๊ฒฐ๊ณผ๋Š” ๋ถ€๋ก์˜ Table 6์—์„œ ์ œ๊ณต๋ฉ๋‹ˆ๋‹ค. ๋ช‡ ๊ฐ€์ง€ ํŒจํ„ด์„ ๊ด€์ฐฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ฒซ์งธ, ๋น„์ „ ํŠธ๋žœ์Šคํฌ๋จธ๋Š” ์„ฑ๋Šฅ/์ปดํ“จํŠธ ๊ตํ™˜์—์„œ ResNet์„ ์••๋„ํ•ฉ๋‹ˆ๋‹ค. ViT๋Š” ๋™์ผํ•œ ์„ฑ๋Šฅ์„ ๋‹ฌ์„ฑํ•˜๊ธฐ ์œ„ํ•ด ์•ฝ 2~4๋ฐฐ ๋” ์ ์€ ์ปดํ“จํŠธ๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค(5๊ฐœ ๋ฐ์ดํ„ฐ์…‹์— ๋Œ€ํ•œ ํ‰๊ท ). ๋‘˜์งธ, ํ•˜์ด๋ธŒ๋ฆฌ๋“œ ๋ชจ๋ธ์€ ์ž‘์€ ์ปดํ“จํŒ… ์˜ˆ์‚ฐ์—์„œ ViT๋ณด๋‹ค ์•ฝ๊ฐ„ ์šฐ์ˆ˜ํ•œ ์„ฑ๋Šฅ์„ ๋ณด์ด์ง€๋งŒ, ๋” ํฐ ๋ชจ๋ธ์— ๋Œ€ํ•ด์„œ๋Š” ์ฐจ์ด๊ฐ€ ์‚ฌ๋ผ์ง‘๋‹ˆ๋‹ค. ์ด ๊ฒฐ๊ณผ๋Š” ํ•œํŽธ์œผ๋กœ๋Š” ์ปจ๋ณผ๋ฃจ์…˜ ์ง€์—ญ ํŠน์ง• ์ฒ˜๋ฆฌ๊ฐ€ ์–ด๋–ค ํฌ๊ธฐ์—์„œ๋“  ViT๋ฅผ ์ง€์›ํ•  ๊ฒƒ์œผ๋กœ ์˜ˆ์ƒํ•  ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ๋‹ค์†Œ ๋†€๋ผ์šด ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์…‹์งธ, Vision Transformer๋Š” ์‹œ๋„ํ•œ ๋ฒ”์œ„ ๋‚ด์—์„œ ํฌํ™”๋˜์ง€ ์•Š๋Š” ๊ฒƒ์œผ๋กœ ๋‚˜ํƒ€๋‚˜๋ฉฐ, ํ–ฅํ›„ ์Šค์ผ€์ผ๋ง ์—ฐ๊ตฌ๋ฅผ ๋…๋ คํ•ฉ๋‹ˆ๋‹ค.

4.5 INSPECTING VISION TRANSFORMER To begin to understand how the Vision Transformer processes image data, we analyze its internal representations. The first layer of the Vision Transformer linearly projects the flattened patches into a lower-dimensional space (Eq. 1). Figure 7 (left) shows the top principal components of the the learned embedding filters. The components resemble plausible basis functions for a low-dimensional representation of the fine structure within each patch. After the projection, a learned position embedding is added to the patch representations. Figure 7 (center) shows that the model learns to encode distance within the image in the similarity of position embeddings, i.e. closer patches tend to have more similar position embeddings. Further, the row-column structure appears; patches in the same row/column have similar embeddings. Finally, a sinusoidal structure is sometimes apparent for larger grids (Appendix D). That the position embeddings learn to represent 2D image topology explains why hand-crafted 2D-aware embedding variants do not yield improvements (Appendix D.4). Self-attention allows ViT to integrate information across the entire image even in the lowest layers. We investigate to what degree the network makes use of this capability. Specifically, we compute the average distance in image space across which information is integrated, based on the attention weights (Figure 7, right). This “attention distance” is analogous to receptive field size in CNNs. We find that some heads attend to most of the image already in the lowest layers, showing that the ability to integrate information globally is indeed used by the model. Other attention heads have consistently small attention distances in the low layers. This highly localized attention is less pronounced in hybrid models that apply a ResNet before the Transformer (Figure 7, right), suggesting that it may serve a similar function as early convolutional layers in CNNs. Further, the attention distance increases with network depth. Globally, we find that the model attends to image regions that are semantically relevant for classification (Figure 6).

4.5 ๋น„์ „ ํŠธ๋žœ์Šคํฌ๋จธ์˜ ๋‚ด๋ถ€ ํ‘œํ˜„ ๋ถ„์„ ๋น„์ „ ํŠธ๋žœ์Šคํฌ๋จธ๊ฐ€ ์ด๋ฏธ์ง€ ๋ฐ์ดํ„ฐ๋ฅผ ์ฒ˜๋ฆฌํ•˜๋Š” ๋ฐฉ์‹์„ ์ดํ•ดํ•˜๊ธฐ ์œ„ํ•ด ๋‚ด๋ถ€ ํ‘œํ˜„์„ ๋ถ„์„ํ•ฉ๋‹ˆ๋‹ค. ๋น„์ „ ํŠธ๋žœ์Šคํฌ๋จธ์˜ ์ฒซ ๋ฒˆ์งธ ๋ ˆ์ด์–ด๋Š” ํŒจ์น˜๋“ค์„ ๋‚ฎ์€ ์ฐจ์›์˜ ๊ณต๊ฐ„์œผ๋กœ ์„ ํ˜• ํˆฌ์˜ํ•ฉ๋‹ˆ๋‹ค (์‹ 1). Figure 7 (์™ผ์ชฝ)์€ ํ•™์Šต๋œ ์ž„๋ฒ ๋”ฉ ํ•„ํ„ฐ์˜ ์ƒ์œ„ ์ฃผ์„ฑ๋ถ„์„ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค. ์ด ์ฃผ์„ฑ๋ถ„๋“ค์€ ๊ฐ ํŒจ์น˜ ๋‚ด์˜ ์„ธ๋ถ€ ๊ตฌ์กฐ์˜ ์ €์ฐจ์› ํ‘œํ˜„์„ ์œ„ํ•œ ํƒ€๋‹นํ•œ ๊ธฐ์ € ํ•จ์ˆ˜์™€ ์œ ์‚ฌํ•ฉ๋‹ˆ๋‹ค. ํˆฌ์˜ ์ดํ›„, ํ•™์Šต๋œ ์œ„์น˜ ์ž„๋ฒ ๋”ฉ์ด ํŒจ์น˜ ํ‘œํ˜„์— ์ถ”๊ฐ€๋ฉ๋‹ˆ๋‹ค. Figure 7 (๊ฐ€์šด๋ฐ)์€ ๋ชจ๋ธ์ด ์œ„์น˜ ์ž„๋ฒ ๋”ฉ์˜ ์œ ์‚ฌ์„ฑ์„ ํ†ตํ•ด ์ด๋ฏธ์ง€ ๋‚ด์˜ ๊ฑฐ๋ฆฌ๋ฅผ ์ธ์ฝ”๋”ฉํ•˜๋Š” ๊ฒƒ์„ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค. ์ฆ‰, ๋” ๊ฐ€๊นŒ์šด ํŒจ์น˜๋Š” ๋ณด๋‹ค ์œ ์‚ฌํ•œ ์œ„์น˜ ์ž„๋ฒ ๋”ฉ์„ ๊ฐ–์Šต๋‹ˆ๋‹ค. ๋˜ํ•œ ํ–‰-์—ด ๊ตฌ์กฐ๊ฐ€ ๋‚˜ํƒ€๋‚ฉ๋‹ˆ๋‹ค. ๊ฐ™์€ ํ–‰/์—ด์— ์žˆ๋Š” ํŒจ์น˜๋“ค์€ ์œ ์‚ฌํ•œ ์ž„๋ฒ ๋”ฉ์„ ๊ฐ–์Šต๋‹ˆ๋‹ค. ๋งˆ์ง€๋ง‰์œผ๋กœ, ๋” ํฐ ๊ทธ๋ฆฌ๋“œ์— ๋Œ€ํ•ด์„œ๋Š” ๋•Œ๋กœ ์‚ฌ์ธ ํ•จ์ˆ˜ ๊ตฌ์กฐ๊ฐ€ ํ™•์ธ๋ฉ๋‹ˆ๋‹ค (๋ถ€๋ก D ์ฐธ์กฐ). ์œ„์น˜ ์ž„๋ฒ ๋”ฉ์ด 2D ์ด๋ฏธ์ง€ ํ† ํด๋กœ์ง€๋ฅผ ํ‘œํ˜„ํ•˜๋Š” ๋ฐฉ์‹์„ ํ•™์Šตํ•œ๋‹ค๋Š” ๊ฒƒ์€ ์ˆ˜๋™์œผ๋กœ ๋งŒ๋“  2D-aware ์ž„๋ฒ ๋”ฉ ๋ณ€ํ˜•์ด ๊ฐœ์„ ๋˜์ง€ ์•Š๋Š” ์ด์œ ๋ฅผ ์„ค๋ช…ํ•ฉ๋‹ˆ๋‹ค (๋ถ€๋ก D.4). ์…€ํ”„ ์–ดํ…์…˜์€ ViT๊ฐ€ ์ตœํ•˜์œ„ ๋ ˆ์ด์–ด์—์„œ๋„ ์ „์ฒด ์ด๋ฏธ์ง€๋ฅผ ํ†ตํ•ฉํ•˜๋Š” ๋Šฅ๋ ฅ์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ์šฐ๋ฆฌ๋Š” ๋„คํŠธ์›Œํฌ๊ฐ€ ์ด ๋Šฅ๋ ฅ์„ ์–ด๋Š ์ •๋„ ํ™œ์šฉํ•˜๋Š”์ง€ ์กฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค. ํŠนํžˆ, ์–ดํ…์…˜ ๊ฐ€์ค‘์น˜๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ์ด๋ฏธ์ง€ ๊ณต๊ฐ„์—์„œ ์ •๋ณด๊ฐ€ ํ†ตํ•ฉ๋˜๋Š” ํ‰๊ท  ๊ฑฐ๋ฆฌ๋ฅผ ๊ณ„์‚ฐํ•ฉ๋‹ˆ๋‹ค (Figure 7, ์˜ค๋ฅธ์ชฝ). ์ด "์–ดํ…์…˜ ๊ฑฐ๋ฆฌ"๋Š” CNN์—์„œ์˜ ์ˆ˜์šฉ์žฅ ํฌ๊ธฐ์— ํ•ด๋‹นํ•ฉ๋‹ˆ๋‹ค. ์ผ๋ถ€ ํ—ค๋“œ๋Š” ์ด๋ฏธ ์ตœํ•˜์œ„ ๋ ˆ์ด์–ด์—์„œ ์ด๋ฏธ์ง€์˜ ๋Œ€๋ถ€๋ถ„์— ์–ดํ…์…˜์„ ์ฃผ๋Š” ๊ฒƒ์œผ๋กœ ๋‚˜ํƒ€๋‚ฉ๋‹ˆ๋‹ค. ์ด๋Š” ๋ชจ๋ธ์ด ์‹ค์ œ๋กœ ์ •๋ณด๋ฅผ ์ „์—ญ์ ์œผ๋กœ ํ†ตํ•ฉํ•˜๋Š” ๋Šฅ๋ ฅ์„ ์‚ฌ์šฉํ•œ๋‹ค๋Š” ๊ฒƒ์„ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค. ๋‹ค๋ฅธ ์–ดํ…์…˜ ํ—ค๋“œ๋Š” ์ตœํ•˜์œ„ ๋ ˆ์ด์–ด์—์„œ ์ผ๊ด€๋˜๊ฒŒ ์ž‘์€ ์–ดํ…์…˜ ๊ฑฐ๋ฆฌ๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ๊ณ ๋„๋กœ ๊ตญ๋ถ€ํ™”๋œ ์–ดํ…์…˜์€ ํŠธ๋žœ์Šคํฌ๋จธ ์ด์ „์— ResNet์„ ์ ์šฉํ•˜๋Š” ํ•˜์ด๋ธŒ๋ฆฌ๋“œ ๋ชจ๋ธ์—์„œ๋Š” ๊ทธ ์ •๋„๊ฐ€ ๋œํ•œ ๊ฒƒ์œผ๋กœ ๋‚˜ํƒ€๋‚ฉ๋‹ˆ๋‹ค (Figure 7, ์˜ค๋ฅธ์ชฝ), ์ด๋Š” ์ด๋Ÿฌํ•œ ์–ดํ…์…˜ ๊ฑฐ๋ฆฌ๊ฐ€ CNN์˜ ์ดˆ๊ธฐ ํ•ฉ์„ฑ๊ณฑ ๋ ˆ์ด์–ด์™€ ์œ ์‚ฌํ•œ ๊ธฐ๋Šฅ์„ ์ˆ˜ํ–‰ํ•  ์ˆ˜๋„ ์žˆ๋‹ค๋Š” ๊ฒƒ์„ ์‹œ์‚ฌํ•ฉ๋‹ˆ๋‹ค. ๋” ๋‚˜์•„๊ฐ€, ์–ดํ…์…˜ ๊ฑฐ๋ฆฌ๋Š” ๋„คํŠธ์›Œํฌ์˜ ๊นŠ์ด์™€ ํ•จ๊ป˜ ์ฆ๊ฐ€ํ•ฉ๋‹ˆ๋‹ค. ์ „์ฒด์ ์œผ๋กœ ๋ชจ๋ธ์€ ๋ถ„๋ฅ˜์— ์˜๋ฏธ ์žˆ๋Š” ์‹œ๋งจํ‹ฑํ•œ ์ด๋ฏธ์ง€ ์˜์—ญ์— ์–ดํ…์…˜์„ ์ง‘์ค‘ํ•ฉ๋‹ˆ๋‹ค (Figure 6).

4.6 SELF-SUPERVISION

Transformers show impressive performance on NLP tasks. However, much of their success stems not only from their excellent scalability but also from large scale self-supervised pre-training (Devlinet al., 2019; Radford et al., 2018). We also perform a preliminary exploration on masked patch prediction for self-supervision, mimicking the masked language modeling task used in BERT. With self-supervised pre-training, our smaller ViT-B/16 model achieves 79.9% accuracy on ImageNet, a significant improvement of 2% to training from scratch, but still 4% behind supervised pre-training. Appendix B.1.2 contains further details. We leave exploration of contrastive pre-training (Chen et al., 2020b; He et al., 2020; Bachman et al., 2019; Henaff et al., 2020) to future work.

4.6 ์ž๊ธฐ-๊ฐ๋… ํ•™์Šต ํŠธ๋žœ์Šคํฌ๋จธ๋Š” NLP ์ž‘์—…์—์„œ ์ธ์ƒ์ ์ธ ์„ฑ๋Šฅ์„ ๋ณด์ž…๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ ๊ทธ๋“ค์˜ ์„ฑ๊ณต์€ ์šฐ์ˆ˜ํ•œ ํ™•์žฅ์„ฑ ๋ฟ๋งŒ ์•„๋‹ˆ๋ผ ๋Œ€๊ทœ๋ชจ ์ž๊ธฐ-๊ฐ๋… ์‚ฌ์ „ ํ•™์Šต (Devlin et al., 2019; Radford et al., 2018) ์—์„œ๋„ ๊ธฐ์ธํ•ฉ๋‹ˆ๋‹ค. ์šฐ๋ฆฌ๋Š” ์ž๊ธฐ-๊ฐ๋… ํ•™์Šต์„ ์œ„ํ•ด ๋งˆ์Šคํฌ๋œ ํŒจ์น˜ ์˜ˆ์ธก์— ๋Œ€ํ•œ ์˜ˆ๋น„์ ์ธ ํƒ์ƒ‰์„ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค. ์ด๋Š” BERT์—์„œ ์‚ฌ์šฉ๋˜๋Š” ๋งˆ์Šคํฌ๋œ ์–ธ์–ด ๋ชจ๋ธ๋ง ์ž‘์—…์„ ๋ชจ๋ฐฉํ•œ ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์ž๊ธฐ-๊ฐ๋… ์‚ฌ์ „ ํ•™์Šต์„ ํ†ตํ•ด ์ž‘์€ ViT-B/16 ๋ชจ๋ธ์€ ImageNet์—์„œ 79.9%์˜ ์ •ํ™•๋„๋ฅผ ๋‹ฌ์„ฑํ•˜๋ฉฐ, ์ฒ˜์Œ๋ถ€ํ„ฐ ํ•™์Šตํ•˜๋Š” ๊ฒƒ๋ณด๋‹ค 2%์˜ ์ƒ๋‹นํ•œ ๊ฐœ์„ ์„ ๋ณด์ž…๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ ์—ฌ์ „ํžˆ ์ง€๋„ ํ•™์Šต ์‚ฌ์ „ ํ•™์Šต๋ณด๋‹ค 4% ๋’ค์ณ์ง‘๋‹ˆ๋‹ค. ๋ถ€๋ก B.1.2์—๋Š” ๋” ์ž์„ธํ•œ ๋‚ด์šฉ์ด ํฌํ•จ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ๋Œ€์กฐ์  ์‚ฌ์ „ ํ•™์Šต (Chen et al., 2020b; He et al., 2020; Bachman et al., 2019; Henaff et al., 2020)์˜ ํƒ๊ตฌ๋Š” ํ–ฅํ›„ ์—ฐ๊ตฌ๋กœ ๋‚จ๊ฒจ๋‘ก๋‹ˆ๋‹ค.

5. Conclusion

We have explored the direct application of Transformers to image recognition. Unlike prior works using self-attention in computer vision, we do not introduce image-specific inductive biases into the architecture apart from the initial patch extraction step. Instead, we interpret an image as a sequence of patches and process it by a standard Transformer encoder as used in NLP. This simple, yet scalable, strategy works surprisingly well when coupled with pre-training on large datasets. Thus, Vision Transformer matches or exceeds the state of the art on many image classification datasets, whilst being relatively cheap to pre-train.

While these initial results are encouraging, many challenges remain. One is to apply ViT to other computer vision tasks, such as detection and segmentation. Our results, coupled with those in Carion et al. (2020), indicate the promise of this approach. Another challenge is to continue exploring selfsupervised pre-training methods. Our initial experiments show improvement from self-supervised pre-training, but there is still large gap between self-supervised and large-scale supervised pretraining. Finally, further scaling of ViT would likely lead to improved performance.

์ €ํฌ๋Š” Transformer๋ฅผ ์ง์ ‘์ ์œผ๋กœ ์ด๋ฏธ์ง€ ์ธ์‹์— ์ ์šฉํ•ด ๋ณด์•˜์Šต๋‹ˆ๋‹ค. ์ด์ „ ์—ฐ๊ตฌ๋“ค๊ณผ๋Š” ๋‹ฌ๋ฆฌ, ์ด๋ฏธ์ง€ ํŠน์ •์˜ ๊ท€๋‚ฉ์  ํŽธํ–ฅ์„ ์ดˆ๊ธฐ ํŒจ์น˜ ์ถ”์ถœ ๋‹จ๊ณ„๋ฅผ ์ œ์™ธํ•˜๊ณ  ์•„ํ‚คํ…์ฒ˜์— ๋„์ž…ํ•˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค. ๋Œ€์‹ , ์ด๋ฏธ์ง€๋ฅผ ํŒจ์น˜์˜ ์‹œํ€€์Šค๋กœ ํ•ด์„ํ•˜๊ณ  NLP์—์„œ ์‚ฌ์šฉ๋˜๋Š” ํ‘œ์ค€ Transformer ์ธ์ฝ”๋”๋กœ ์ฒ˜๋ฆฌํ–ˆ์Šต๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ๊ฐ„๋‹จํ•˜๋ฉด์„œ๋„ ํ™•์žฅ ๊ฐ€๋Šฅํ•œ ์ „๋žต์€ ๋Œ€์šฉ๋Ÿ‰ ๋ฐ์ดํ„ฐ์…‹์—์„œ์˜ ์‚ฌ์ „ ํ•™์Šต๊ณผ ๊ฒฐํ•ฉํ•  ๋•Œ ๋†€๋ž๋„๋ก ์ž˜ ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ Vision Transformer๋Š” ๋งŽ์€ ์ด๋ฏธ์ง€ ๋ถ„๋ฅ˜ ๋ฐ์ดํ„ฐ์…‹์—์„œ ์ตœ์‹  ๊ธฐ์ˆ  ์ˆ˜์ค€์„ ๋‹ฌ์„ฑํ•˜๊ฑฐ๋‚˜ ๋›ฐ์–ด๋„˜์œผ๋ฉฐ, ์ƒ๋Œ€์ ์œผ๋กœ ์‚ฌ์ „ ํ•™์Šต ๋น„์šฉ์ด ์ €๋ ดํ•ฉ๋‹ˆ๋‹ค.

์ด ์ดˆ๊ธฐ ๊ฒฐ๊ณผ๋Š” ๊ฒฉ๋ ค๋˜๋Š” ๊ฒฐ๊ณผ์ด์ง€๋งŒ, ๋งŽ์€ ๋„์ „ ๊ณผ์ œ๋“ค์ด ๋‚จ์•„ ์žˆ์Šต๋‹ˆ๋‹ค. ํ•˜๋‚˜๋Š” ViT๋ฅผ ํƒ์ง€ ๋ฐ ์„ธ๊ทธ๋ฉ˜ํ…Œ์ด์…˜๊ณผ ๊ฐ™์€ ๋‹ค๋ฅธ ์ปดํ“จํ„ฐ ๋น„์ „ ์ž‘์—…์— ์ ์šฉํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์šฐ๋ฆฌ์˜ ๊ฒฐ๊ณผ์™€ Carion et al. (2020)์˜ ๊ฒฐ๊ณผ๋Š” ์ด ์ ‘๊ทผ ๋ฐฉ์‹์˜ ์ž ์žฌ๋ ฅ์„ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค. ๋˜ ๋‹ค๋ฅธ ๋„์ „์€ ์ž๊ธฐ-๊ฐ๋… ์‚ฌ์ „ ํ•™์Šต ๋ฐฉ๋ฒ•์„ ๊ณ„์† ํƒ๊ตฌํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์ดˆ๊ธฐ ์‹คํ—˜ ๊ฒฐ๊ณผ๋Š” ์ž๊ธฐ-๊ฐ๋… ์‚ฌ์ „ ํ•™์Šต์—์„œ์˜ ๊ฐœ์„ ์„ ๋ณด์—ฌ์ฃผ์ง€๋งŒ, ์ž๊ธฐ-๊ฐ๋… ์‚ฌ์ „ ํ•™์Šต๊ณผ ๋Œ€๊ทœ๋ชจ ์ง€๋„ ํ•™์Šต ์‚ฌ์ „ ํ•™์Šต ์‚ฌ์ด์—๋Š” ์—ฌ์ „ํžˆ ํฐ ๊ฒฉ์ฐจ๊ฐ€ ๋‚จ์•„ ์žˆ์Šต๋‹ˆ๋‹ค. ๋งˆ์ง€๋ง‰์œผ๋กœ, ViT์˜ ์ถ”๊ฐ€์ ์ธ ํ™•์žฅ์€ ์„ฑ๋Šฅ ํ–ฅ์ƒ์œผ๋กœ ์ด์–ด์งˆ ๊ฒƒ์œผ๋กœ ์˜ˆ์ƒ๋ฉ๋‹ˆ๋‹ค.


๐Ÿ’ก
<๋ฆฌ๋ทฐ>
1. Intro
  • Transformer ๊ตฌ์กฐ์˜ NLP task์—์„œ์˜ ์„ฑ๊ณต
  • ํ•˜์ง€๋งŒ, Computer Vision Task์—์„œ๋Š” ์ œ๋Œ€๋กœ ์ ์šฉ์ด ์ด๋ฃจ์–ด์ง€์ง€ ์•Š์Œ.
  • Self-Attention์„ ์ถ”๊ฐ€ํ•œ CNN ๊ณ„์—ด ๋ชจ๋ธ ๊ตฌ์กฐ์™€ ์•„์˜ˆ convolution์„ attention์œผ๋กœ ๋Œ€์ฒดํ•œ ๊ตฌ์กฐ๋“ค์ด ์ œ์•ˆ๋จ. ๊ทธ๋Ÿฌ๋‚˜, ์ด๋ก ์ ์œผ๋กœ๋Š” ํšจ์œจ์„ฑ์ด ๋ณด์žฅ๋˜์—ˆ์ง€๋งŒ ์‹ค์ œ ํ•˜๋“œ์›จ์–ด ๊ฐ€์†๊ธฐ์™€์˜ ํ˜ธํ™˜์„ฑ์ด ๋–จ์–ด์ง.

์ด๋ฏธ์ง€๋ฅผ ํŒจ์น˜(patch)๋กœ ๋ถ„ํ• ํ•˜๊ณ , ์ด๋Ÿฌํ•œ ํŒจ์น˜๋“ค์˜ ์„ ํ˜• ์ž„๋ฒ ๋”ฉ(sequence of linear embeddings)์„ Transformer์˜ ์ž…๋ ฅ์œผ๋กœ ์ œ๊ณต. ์ด๋ฏธ์ง€ ํŒจ์น˜๋Š” NLP ์‘์šฉํ”„๋กœ๊ทธ๋žจ์—์„œ์˜ ํ† ํฐ(๋‹จ์–ด)๊ณผ ๋™์ผํ•˜๊ฒŒ ์ฒ˜๋ฆฌ์‹œํ‚ค๊ณ ์ž ํ•จ.

๐Ÿ“Œ Inductive bias

: ํ•™์Šต ์‹œ ๋งŒ๋‚˜๋ณด์ง€ ๋ชปํ–ˆ๋˜ ์ƒํ™ฉ์— ๋Œ€ํ•ด ์ •ํ™•ํ•œ ์˜ˆ์ธก์„ ํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉํ•˜๋Š” ์ถ”๊ฐ€์ ์ธ ๊ฐ€์ •์„ ์˜๋ฏธํ•จ (์‚ฌ์ „ ์ •๋ณด๋ฅผ ํ†ตํ•ด ์ถ”๊ฐ€๋œ ๊ฐ€์ •)

  1. CNN: Vision ์ •๋ณด๋Š” ์ธ์ ‘ ํ”ฝ์…€๊ฐ„์˜ locality(๊ทผ์ ‘ ํ”ฝ์…€๋ผ๋ฆฌ์˜ ์ข…์†์„ฑ)๊ฐ€ ์กด์žฌํ•œ๋‹ค๋Š” ๊ฒƒ์„ ๋ฏธ๋ฆฌ ์•Œ๊ณ  ์žˆ๊ธฐ ๋•Œ๋ฌธ์— Conv๋Š” ์ธ์ ‘ ํ”ฝ์…€๊ฐ„์˜ ์ •๋ณด๋ฅผ ์ถ”์ถœํ•˜๊ธฐ ์œ„ํ•œ ๋ชฉ์ ์œผ๋กœ ์„ค๊ณ„๋˜์–ด Conv์˜ inductive bias๊ฐ€ local ์˜์—ญ์—์„œ spatial ์ •๋ณด๋ฅผ ์ž˜ ๋ฝ‘์•„๋ƒ„.+ transitional Invariance(์‚ฌ๋ฌผ ์œ„์น˜๊ฐ€ ๋ฐ”๋€Œ์–ด๋„ ๋™์ผ ์‚ฌ๋ฌผ ์ธ์‹)๋“ฑ์˜ ํŠน์„ฑ์„ ๊ฐ€์ง€๊ธฐ ๋•Œ๋ฌธ์— ์ด๋ฏธ์ง€ ๋ฐ์ดํ„ฐ์— ์ ํ•ฉํ•œ ๋ชจ๋ธ์ž„
  1. ๋ฐ˜๋ฉด, MLP์˜ ๊ฒฝ์šฐ, all(input)-to-all (output) ๊ด€๊ณ„๋กœ ๋ชจ๋“  weight๊ฐ€ ๋…๋ฆฝ์ ์ด๋ฉฐ ๊ณต์œ ๋˜์ง€ ์•Š์•„ inductive bias๊ฐ€ ๋งค์šฐ ์•ฝํ•จ.
  1. Transformer๋Š” attention์„ ํ†ตํ•ด ์ž…๋ ฅ ๋ฐ์ดํ„ฐ์˜ ๋ชจ๋“  ์š”์†Œ๊ฐ„์˜ ๊ด€๊ณ„๋ฅผ ๊ณ„์‚ฐํ•˜๋ฏ€๋กœ CNN๋ณด๋‹ค๋Š” Inductive Bias๊ฐ€ ์ž‘๋‹ค๋ผ๊ณ  ํ•  ์ˆ˜ ์žˆ์Œ.

→ CNN > Transformer > Fully Connected

→ inductive bias๊ฐ€ ์ปค์งˆ์ˆ˜๋ก generalizaion์ด ๋–จ์–ด์ง (๋‘˜์€ trade off ๊ด€๊ณ„)

What is inductive bias?
8๋งŒ AI ํŒ€์ด ํ˜‘์—…ํ•˜๋Š” ๋ฐ์ดํ„ฐ ์‚ฌ์ด์–ธ์Šค ํ”Œ๋žซํผ. AI ๊ฒฝ์ง„๋Œ€ํšŒ์™€ ๋Œ€์ƒ ๋งž์ถค ์˜จ/์˜คํ”„๋ผ์ธ ๊ต์œก, ๋ฌธ์ œ ๊ธฐ๋ฐ˜ ํ•™์Šต ์„œ๋น„์Šค๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.
https://dacon.io/en/forum/405840

What is inductive bias?
8๋งŒ AI ํŒ€์ด ํ˜‘์—…ํ•˜๋Š” ๋ฐ์ดํ„ฐ ์‚ฌ์ด์–ธ์Šค ํ”Œ๋žซํผ. AI ๊ฒฝ์ง„๋Œ€ํšŒ์™€ ๋Œ€์ƒ ๋งž์ถค ์˜จ/์˜คํ”„๋ผ์ธ ๊ต์œก, ๋ฌธ์ œ ๊ธฐ๋ฐ˜ ํ•™์Šต ์„œ๋น„์Šค๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.
https://dacon.io/en/forum/405840
2. Related Work

1. NLP

  • Vaswani et al. (2017): Transformer ๊ตฌ์กฐ๋ฅผ ๊ธฐ๊ณ„ ๋ฒˆ์—ญ ๋ชจ๋ธ๋กœ ์ฒ˜์Œ ์ œ์•ˆ. ํ˜„์žฌ ๋งŽ์€ NLP Task์—์„œ ๊ฐ€์žฅ ์ข‹์€ ์„ฑ๋Šฅ์„ ๋ณด์—ฌ์ฃผ๋Š” ๊ตฌ์กฐ
  • Devlin et al. (2019): BERT๋ฅผ ์ œ์•ˆ. ๋…ธ์ด์ฆˆ๋ฅผ ์ œ๊ฑฐํ•˜๋Š” ์ž๊ธฐ์ง€๋„ ์‚ฌ์ „ํ•™์Šต์„ ์ˆ˜ํ–‰.
  • GPT ๊ณ„์—ด (2018, 2019, 2020): ์–ธ์–ด ๋ชจ๋ธ์„ ์‚ฌ์ „ํ•™์Šต ํƒœ์Šคํฌ๋กœ ์„ ์ •ํ•˜์—ฌ ์ˆ˜ํ–‰.

2. Computer Vision

  • self-attention์„ ์ด๋ฏธ์ง€์— ๋‹จ์ˆœ ์ ์šฉํ•˜๋Š” ๋ฐฉ์‹์€ ํ•ด๋‹น ํ”ฝ์…€๊ณผ ๋ชจ๋“  ํ”ฝ์…€ ๊ฐ„์˜ attention weight์„ ๊ตฌํ•ด์•ผ ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ๊ณ„์‚ฐ๋น„์šฉ์ด pixel ๊ฐœ์ˆ˜ n์— ๋Œ€ํ•˜์—ฌ O(n2)์˜ ๋ณต์žก๋„๋ฅผ ๊ฐ€์ง.
  • Parmar et al. (2018): local neighborhood์—๋งŒ self-attention์„ ์ ์šฉ.
  • Sparse Transformers (2019), Weissenborn et al. (2019): attention์˜ ๋ฒ”์œ„๋ฅผ scalingํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ self-attention์„ ์ ์šฉํ•˜๊ณ ์ž ํ•จ.

→ ์ด๋Ÿฌํ•œ ํŠน๋ณ„ํ•œ ๋ฐฉ์‹์˜ attention์˜ ๊ฒฝ์šฐ์—๋Š” ํ•˜๋“œ์›จ์–ด ๊ฐ€์†๊ธฐ์—์„œ ์—ฐ์‚ฐ์„ ํšจ์œจ์ ์œผ๋กœ ์ˆ˜ํ–‰ํ•˜๊ธฐ์—๋Š” ๋‹ค์†Œ ๋ฒˆ๊ฑฐ๋กœ์šด ์ž‘์—…์ด ํฌํ•จ๋˜์–ด ์žˆ๋Š” ๊ฒฝ์šฐ๊ฐ€ ๋‹ค์ˆ˜.

  • Cordonnier et al. (2020): ์ด๋ฏธ์ง€๋ฅผ 2x2์˜ ํŒจ์น˜๋กœ ์ชผ๊ฐ  ํ›„, ์ด์— self-attention์„ ์ ์šฉํ•จ. ์œ„์™€ ๊ฐ™์€ ์ ์—์„œ ViT์™€ ๋งค์šฐ ์œ ์‚ฌํ•˜๋‚˜, ์ด๋ฏธ์ง€ ํŒจ์น˜๊ฐ€ ๋งค์šฐ ์ž‘์œผ๋ฏ€๋กœ ์ €ํ•ด์ƒ๋„ ์ž…๋ ฅ ์ด๋ฏธ์ง€์—๋งŒ ์ ์šฉ์ด ๊ฐ€๋Šฅํ•˜๋‹ค๋Š” ๋‹จ์ ์ด ์žˆ์Œ. ViT์˜ ๊ฒฝ์šฐ์—๋Š” ์ค‘ํ•ด์ƒ๋„ ์ด๋ฏธ์ง€๋ฅผ ๋‹ค๋ฃฐ ์ˆ˜ ์žˆ๋‹ค๋Š” ์ , Vanilla Transformer ๊ตฌ์กฐ๋ฅผ ์ฐจ์šฉํ•ด ๊ธฐ์กด์˜ SOTA CNN๋ณด๋‹ค ๋” ์ข‹์€ ์„ฑ๋Šฅ์„ ์ฆ๋ช…ํ•ด๋ƒˆ๋‹ค๋Š” ์ ์—์„œ ํ•ด๋‹น ์—ฐ๊ตฌ๋ณด๋‹ค ์šฐ์œ„๋ฅผ ๊ฐ€์ง.
  • image GPT (Chen et al., 2020): ์ด๋ฏธ์ง€ ํ•ด์ƒ๋„์™€ color space๋ฅผ ์ค„์ธ ํ›„, image pixel ๋‹จ์œ„๋กœ Transformer๋ฅผ ์ ์šฉํ•œ ์ƒ์„ฑ ๋ชจ๋ธ.

⇒ ๊ธฐ์กด ์—ฐ๊ตฌ ๋Œ€๋น„ ViT์˜ ์ฐจ๋ณ„์ 

  • ํ‘œ์ค€ ImageNet ๋ฐ์ดํ„ฐ์…‹๋ณด๋‹ค ๋” ํฐ ํฌ๊ธฐ์˜ ๋ฐ์ดํ„ฐ์…‹์—์„œ image recognition ์‹คํ—˜์„ ์ง„ํ–‰.
  • ๋” ํฐ ํฌ๊ธฐ์˜ ๋ฐ์ดํ„ฐ์…‹์—์„œ ํ•™์Šต์‹œํ‚ด์œผ๋กœ์จ ๊ธฐ์กด์˜ ResNet ๊ธฐ๋ฐ˜ CNN๋ณด๋‹ค ๋” ์ข‹์€ ์„ฑ๋Šฅ์„ ๋‚ผ ์ˆ˜ ์žˆ์—ˆ์Œ.
3. Method
  • ๋ชจ๋ธ์—์„œ๋Š” ์›๋ž˜์˜ transformer์„ ๋”ฐ๋ฅด๋„๋ก ๋…ธ๋ ฅํ•˜๊ณ ์ž ํ–ˆ์Œ.→ ์ด์— ๋Œ€ํ•œ ์žฅ์ : NLP transformer ์•„ํ‚คํ…์ฒ˜์™€ ํšจ์œจ์ ์ธ ๊ตฌํ˜„์ด ๊ฑฐ์˜ ๊ทธ๋Œ€๋กœ ์‚ฌ์šฉ๋  ์ˆ˜ ์žˆ์Œ.

3.1) VISION TRANSFORMER (VIT)

1) Step 1.
  • Transformer์˜ input ๊ฐ’์€ 1์ฐจ์› ์‹œํ€€์Šค.
  • ๋”ฐ๋ผ์„œ ๊ณ ์ •๋œ ํฌ๊ธฐ์˜ patch๋กœ ๋‚˜๋ˆ ์ค€ ์ด๋ฏธ์ง€๋ฅผ 1์ฐจ์› ์‹œํ€€์Šค๋กœ flatten ํ•ด์ค˜์•ผ ํ•จ
    ⇒ H*W*C → N*(P*P*C)๋กœ ๋ณ€ํ™˜
    ex) 256*256*3 ⇒ ((256*256)/9^2)* (9*9*3)
  • โ€ป N(์‹œํ€€์Šค ์ˆ˜) = H*W/(P^2) , P= ํŒจ์น˜ ๊ฐœ์ˆ˜

2) Step 2.
  • 1์ฐจ์› ์ด๋ฏธ์ง€๋ฅผ Transformer์— ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” D์ฐจ์›์˜ ๋ฒกํ„ฐ๋กœ ๋ฐ”๊ฟ”์คŒ.→ ์ด ๋ณ€ํ™˜์˜ ์ถœ๋ ฅ์„ ํŒจ์น˜ ์ž„๋ฒ ๋”ฉ์ด๋ผ๊ณ  ํ•จ

3) Step 3.

  • ( Learnable class embedding + ํŒจ์น˜ embedding ) + position embedding
  • learnable class embedding⇒ ์ž„๋ฒ ๋”ฉ๋œ ํŒจ์น˜ ์‹œํ€€์Šค์—
    ํ•™์Šต๊ฐ€๋Šฅํ•œ ์ž„๋ฒ ๋”ฉ์„ ์•ž์— ์ถ”๊ฐ€์‹œ
    ํ‚ด
    → ๋ชจ๋ธ์˜ ํŒŒ๋ผ๋ฏธํ„ฐ๋กœ์จ ๋ฐ์ดํ„ฐ์˜ ํŠน์„ฑ๊ณผ ์ž‘์—…์— ๋งž๊ฒŒ ์ตœ์ ํ™”๋˜๋Š” ๊ฐ’. ํ•™์Šต ๊ณผ์ •์—์„œ ์—…๋ฐ์ดํŠธ๋˜๋Š” ๊ฐ€์ค‘์น˜๋ฅผ ์˜๋ฏธ → (์ด๋Š” ์ถ”ํ›„ ์ด๋ฏธ์ง€ ์ „์ฒด์— ๋Œ€ํ•œ ํ‘œํ˜„์„ ๋‚˜ํƒ€๋‚ด๊ฒŒ ๋จ)
  • โ€ป ํ•™์Šต ๊ฐ€๋Šฅํ•œ ์ž„๋ฒ ๋”ฉ์„ ์‚ฌ์šฉํ•˜๋ฉด ๋ชจ๋ธ์ด ์ด๋ฏธ์ง€ ๋ฐ์ดํ„ฐ์˜ ํŒจํ„ด๊ณผ ํŠน์ง•์„ ์ง์ ‘ ํ•™์Šตํ•˜์—ฌ ๋ฐ์ดํ„ฐ์— ๋งž๋Š” ํšจ๊ณผ์ ์ธ ์ž„๋ฒ ๋”ฉ์„ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ์Œ.
  • position embedding 1D positional embedding: ์™ผ์ชฝ ์œ„๋ถ€ํ„ฐ ์˜ค๋ฅธ์ชฝ ์•„๋ž˜์™€ ๊ฐ™์ด ์ฐจ๋ก€๋กœ ์ˆœ์„œ๋ฅผ ๋งค๊ธฐ๋Š” ๊ฒƒ์„ ์˜๋ฏธ → relative positional embedding: ํŒจ์น˜๋“ค ์‚ฌ์ด์˜ ์ƒ๋Œ€์  ๊ฑฐ๋ฆฌ๋ฅผ ํ™œ์šฉํ•œ positional embedding
  • → 2D positional embedding: 2์ฐจ์›์— ๋Œ€ํ•ด x,y์ถ•์— ๋Œ€ํ•œ ์ขŒํ‘œ๊ฐ€ ์žˆ๋Š” positional embedding

4) Step 4.
  • ์ž„๋ฒ ๋”ฉ์„ transformer encoder์— input์œผ๋กœ ๋„ฃ์–ด ๋งˆ์ง€๋ง‰ layer์—์„œ class embedding์— ๋Œ€ํ•œ output์ธ image representation์„ ๋„์ถœํ•จ

5) Step 5.
  • MLP์— image representation์„ input์œผ๋กœ ๋„ฃ์–ด ์ด๋ฏธ์ง€์˜ class๋ฅผ ๋ถ„๋ฅ˜
  • MLP: ๋‘ ๊ฐœ์˜ fully connected ์ธต์œผ๋กœ ๊ตฌ์„ฑ, GELU ๋น„์„ ํ˜• ํ•จ์ˆ˜ ๋„์ž….

+ VIT ์ˆ˜์‹ ver

→ z0: patch์— ๋Œ€ํ•œ ์ •๋ณด + position embedding์˜ ํ•ฉ

→ z’l: normalization์„ ์ง„ํ–‰ํ•˜๊ณ , multi-head self- attention ์ˆ˜ํ–‰ํ•œ ํ›„, ์ž”์ฐจ ๋”ํ•ด์คŒ

→ zl: normalization ํ•œ ๋ฒˆ ๋” ์ˆ˜ํ–‰ ํ›„, MLP ์ ์šฉ ํ›„, ์ž”์ฐจ ๋”ํ•ด์คŒ

→ y: ๋งˆ์ง€๋ง‰ ์˜ˆ์ธก๊ฐ’์— normalization ํ•œ ๋ฒˆ ๋” ์ ์šฉ

3.2) Inductive Bias

  • VIT์—์„œ์˜ MLP๋Š” ์ด๋ฏธ input์—์„œ ํŒจ์น˜ ๋‹จ์œ„๋กœ ์ž…๋ ฅ๊ฐ’์„ ๋ฐ›๊ธฐ์— ์ •๋ณด๊ฐ€ ์กด์žฌํ•จ. (locality + translation equivariance o)
  • self attention ๋ ˆ์ด์–ด๋Š” ์ž…๋ ฅ ์‹œํ€€์Šค์˜ ๋ชจ๋“  ์œ„์น˜ ๊ฐ„์˜ ์ƒํ˜ธ์ž‘์šฉ์„ ์ˆ˜ํ–‰ํ•จ. (x)โ€ป Self-attention์€ ์ž…๋ ฅ ์‹œํ€€์Šค ๋‚ด์˜ ๊ฐ ์œ„์น˜๊ฐ€ ๋‹ค๋ฅธ ์œ„์น˜์™€ ์–ผ๋งˆ๋‚˜ ๊ด€๋ จ๋˜์–ด ์žˆ๋Š”์ง€๋ฅผ ๊ณ„์‚ฐํ•˜์—ฌ ์ค‘์š”๋„๋ฅผ ๋ถ€์—ฌํ•จ. ์ด๋ฅผ ํ†ตํ•ด ์‹œํ€€์Šค ๋‚ด์˜ ์ž„์˜์˜ ์œ„์น˜๊ฐ€ ์ „์ฒด ์‹œํ€€์Šค์˜ ๋‹ค๋ฅธ ์œ„์น˜์™€ ์ƒํ˜ธ์ž‘์šฉํ•  ์ˆ˜ ์žˆ์Œ. ๋”ฐ๋ผ์„œ self-attention์€ ์ž…๋ ฅ ์‹œํ€€์Šค์˜ ๊ธธ์ด๋‚˜ ์œ„์น˜์— ๋Œ€ํ•ด ์ƒ๊ด€์—†์ด ๋ชจ๋“  ์œ„์น˜ ๊ฐ„์˜ ๊ด€๊ณ„๋ฅผ ๋ชจ๋ธ๋งํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ, ์ด๋ฅผ ํ†ตํ•ด ์ „์—ญ์ ์ธ ์ •๋ณด๋ฅผ ์ €์žฅํ•  ์ˆ˜ ์žˆ์Œ.
  • โ€ป ๋ฐ˜๋ฉด์— MLP ๋ ˆ์ด์–ด๋Š” ์ž…๋ ฅ ์œ„์น˜์™€ ์ง์ ‘์ ์œผ๋กœ ์—ฐ๊ฒฐ๋˜์–ด ์žˆ์œผ๋ฉฐ, ์ง€์—ญ์ ์ธ ํŠน์ง•์„ ๋ชจ๋ธ๋งํ•จ. ์ด ๋ ˆ์ด์–ด๋Š” ์ž…๋ ฅ ์œ„์น˜์— ๋Œ€ํ•œ ํŠน์ง• ๋ณ€ํ™˜์„ ์ˆ˜ํ–‰ํ•˜๋ฏ€๋กœ, ์ด๋™ ๋ถˆ๋ณ€์„ฑ์„ ๊ฐ€์ง€๊ฒŒ ๋จ. MLP๋Š” ์ž…๋ ฅ ์œ„์น˜์— ๋Œ€ํ•ด ๋…๋ฆฝ์ ์œผ๋กœ ์ž‘๋™ํ•˜๋ฉฐ, ์ž…๋ ฅ์˜ ์ˆœ์„œ๋‚˜ ์œ„์น˜์— ์˜ํ–ฅ์„ ๋ฐ›์ง€ ์•Š์Œ.
→ ์ฆ‰, VIT์—์„œ MLP๋Š” locality์™€ translation equivariance๊ฐ€ ์žˆ์ง€๋งŒ, MSA๋Š” globalํ•˜๊ธฐ ๋•Œ๋ฌธ์— CNN๋ณด๋‹ค image- specific inductive bias๊ฐ€ ๋‚ฎ์Œ

→ ViT์—์„œ๋Š” ๋ชจ๋ธ์— ์•„๋ž˜ ๋‘ ๊ฐ€์ง€ ๋ฐฉ๋ฒ•์„ ๋„์ž…ํ•ด, inductive bias์˜ ์ฃผ์ž…์„ ์‹œ๋„ํ•˜๊ณ ์ž ํ•จ.

1) Patch extraction:

ํŒจ์น˜ ๋‹จ์œ„๋กœ ๋ถ„ํ• ํ•˜์—ฌ, ์ˆœ์„œ๊ฐ€ ์กด์žฌํ•˜๋Š” ํ˜•ํƒœ๋กœ ์ž…๋ ฅ์— ๋„ฃ์Œ

→ ์ด๋ฅผ ํ†ตํ•ด ๊ธฐ์กด MLP์™€๋Š” ๋‹ค๋ฅด๊ฒŒ, locality์™€ translation equivariance๊ฐ€ ๋‚ด์žฌ๋จ.

2) Resolution adjustment:

fine tuning ์‹œ์— ์ง„ํ–‰๋จ. ์ž…๋ ฅ ์ด๋ฏธ์ง€์˜ ํฌ๊ธฐ๊ฐ€ ๋‹ฌ๋ผ์งˆ ๊ฒฝ์šฐ, ํŒจ์น˜ ํฌ๊ธฐ๋Š” ๋™์ผํ•˜์ง€๋งŒ, ์ƒ์„ฑ๋˜๋Š” ํŒจ์น˜ ๊ฐœ์ˆ˜๊ฐ€ ๋‹ฌ๋ผ์ง€๊ธฐ์—, positional embedding์„ ์กฐ์ •ํ•ด์•ผ ๋จ → ์ด๋ฅผ ํ†ตํ•ด inductive bias๊ฐ€ ์ฃผ์ž….

3.3) Hybrid Architecture

  • VIT๋Š” raw image๊ฐ€ ์•„๋‹Œ CNN์œผ๋กœ ์ถ”์ถœํ•œ raw image์˜ feature map์„ ํ™œ์šฉํ•˜๋Š” hybrid architecture๋กœ๋„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Œ
  • feature map์˜ ๊ฒฝ์šฐ, ์ด๋ฏธ raw image์˜ ๊ณต๊ฐ„์  ์ •๋ณด๋ฅผ ํฌํ•จํ•˜๊ณ  ์žˆ๊ธฐ์— hybrid architecture๋Š” ํŒจ์น˜ ํฌ๊ธฐ๋ฅผ 1x1๋กœ ์„ค์ •ํ•ด๋„ ๋จ
  • 1x1 ํŒจ์น˜๋ฅผ ์‚ฌ์šฉํ•  ๊ฒฝ์šฐ ํ”ผ์ฒ˜๋งต์˜ ๊ณต๊ฐ„ ์ฐจ์›์„ flattenํ•˜์—ฌ ๊ฐ ๋ฒกํ„ฐ์— linear projection ์ ์šฉํ•˜๋ฉด ๋จ

3.4) FINE-TUNING AND HIGHER RESOLUTION

  • transformer encoder๋Š” ๊ทธ๋Œ€๋กœ ์‚ฌ์šฉํ•˜๋˜, MLP head (MLP์˜ ์ถœ๋ ฅ์„ ์ž…๋ ฅ์œผ๋กœ ๋ฐ›์•„ ์ตœ์ข… ์˜ˆ์ธก๊ฐ’ ๋งŒ๋“œ๋Š” ์—ญํ• )์„ 0์œผ๋กœ ์ดˆ๊ธฐํ™”. (์ดˆ๊ธฐํ™” ๋ฐฉ๋ฒ•์œผ๋กœ ์ƒ๊ฐํ•˜๋ฉด ๋  ๋“ฏ)โ€ป pre-trained prediction head: ์ด๋ฏธ์ง€ ๋ถ„๋ฅ˜ ์ž‘์—…์—์„œ๋Š” ์˜ˆ์ธก ํ—ค๋“œ๊ฐ€ ํด๋ž˜์Šค ์ˆ˜์— ํ•ด๋‹นํ•˜๋Š” ์ถœ๋ ฅ ๋…ธ๋“œ๋ฅผ ๊ฐ€์ง€๊ณ , ๊ฐ ํด๋ž˜์Šค์— ๋Œ€ํ•œ ํ™•๋ฅ ์„ ์˜ˆ์ธกํ•จ.→ ViT๋Š” ๊ฐ€๋ณ€์  ํŒจ์น˜๋“ค์„ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ์ง€๋งŒ, pre-trained position embedding์€ ์˜๋ฏธ๊ฐ€ ์‚ฌ๋ผ์ง€๊ธฐ ๋•Œ๋ฌธ์—, pretrained position embedding์„ ์›๋ณธ ์ด๋ฏธ์ง€ ์œ„์น˜์— ๋”ฐ๋ผ 2D ๋ณด๊ฐ„(interpolation) ์‚ฌ์šฉ
  • → ViT๋ฅผ fine tuning ํ•  ๋•Œ, pre-training๊ณผ ๋™์ผํ•œ ํŒจ์น˜ ํฌ๊ธฐ๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ๋•Œ๋ฌธ์—, ๊ณ ํ•ด์ƒ๋„ ์ด๋ฏธ์ง€๋กœ fine-tuning์„ ํ•  ๊ฒฝ์šฐ, sequence์˜ ๊ธธ์ด๊ฐ€ ๋” ๊ธธ์–ด์ง.
4. Experiments
  • ViT๋Š” class์™€ ์ด๋ฏธ์ง€ ๊ฐœ์ˆ˜๊ฐ€ ๊ฐ๊ฐ ๋‹ค๋ฅธ 3๊ฐœ์˜ ๋ฐ์ดํ„ฐ์…‹์„ ๊ธฐ๋ฐ˜์œผ๋กœ pre-train ๋จ
  • ์•„๋ž˜์˜ benchmark tasks๋ฅผ downstream tast๋กœ ํ•˜์—ฌ pre-trained ViT์˜ representation ์„ฑ๋Šฅ์„ ๊ฒ€์ฆํ•จ
  • ์™ผ์ชฝ: embedding filter์„ ์‹œ๊ฐํ™”ํ•œ ๊ฒฐ๊ณผ→ ๋งŽ์€ ๋ฐ์ดํ„ฐ๋ฅผ pre-trainingํ•˜๋ฉด, embedding filter๊ฐ€ CNN filter์™€ ๋น„์Šทํ•œ ๊ธฐ๋Šฅ์„ ๋ณด์ž„
  • ๊ฐ€์šด๋ฐ: position embedding์„ ์‹œ๊ฐํ™”ํ•œ ๊ฒฐ๊ณผ→ ๊ฐ๊ฐ์˜ ์œ„์น˜๋ฅผ ์ž˜ ํ•™์Šตํ•จ (๋…ธ๋ž€์ƒ‰ ๋ถ€๋ถ„ ํ™•์ธ ex ๊ฐ€์šด๋ฐ ๋ถ€๋ถ„์€ ๊ฐ€์šด๋ฐ์— ๋…ธ๋ž€์ƒ‰์œผ๋กœ, ์•„๋ž˜์ชฝ์œผ๋กœ ๊ฐˆ์ˆ˜๋ก ์•„๋ž˜์— ๋…ธ๋ž€์ƒ‰์ด ์กด์žฌ)
  • ์˜ค๋ฅธ์ชฝ: ๋‚ฎ์€ layer์—์„œ๋Š” CNN์˜ ๋‚ฎ์€ layer์ฒ˜๋Ÿผ ๊ฐ๊ฐ์˜ ์ด๋ฏธ์ง€๋ฅผ ๋‚˜ํƒ€๋ƒ„→ ๋งˆ์ง€๋ง‰์œผ๋กœ ๊ฐˆ์ˆ˜๋ก ์ด๋ฏธ์ง€์˜ ํ†ตํ•ฉ์ ์ธ ๋ชจ์Šต์„ ๋‚˜ํƒ€๋ƒ„
728x90
๋ฐ˜์‘ํ˜•

'Deep Learning > [๋…ผ๋ฌธ] Paper Review' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

U-Net  (0) 2023.07.05
Bert  (0) 2023.07.05
RetinaNet  (0) 2023.07.05
GPT-1  (0) 2023.07.05
DeepLab V2: Semantic Image Segmentation with Convolutional Nets, Atrous Convolution and Fully Connected CRFs  (0) 2023.07.05