반응형

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

 

Alexey Dosovitskiy∗,† , Lucas Beyer∗ , Alexander Kolesnikov∗ , Dirk Weissenborn∗ , Xiaohua Zhai∗ , Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob Uszkoreit, Neil Houlsby∗,†

Google Research, Brain Team

 

ABSTRACT

Transformer architecture는 NLP task의 de-facto standard이 되었지만, computer vision에 대한 적용은 여전히 제한적이다. vision 분야에서 , attention 는 convolutional networks와 함께 적용되거나 전체 구조를 유지하면서 convolutional networks의 certain components 를 대체하는데 사용한다. 우리는 CNNs 에 대한 이러한 의존이 필요하지 않으며  image patches sequences 에 직접 적용된 pure transformer가 image classification tasks에서 매우 잘 수행할 수 있음을 보여준다. large amounts of data에 대해 pre-trained을 받고 multiple mid-sized  혹은 small image recognition benchmarks (ImageNet, CIFAR-100, VTAB, etc.)로 transferred 했을 때 , Vision Transformer (ViT) 는 state-of-the-art convolutional networks에 비해 우수한 결과를 얻으며 , 학습에 필요한 computational resources가 상당히 작다. 

de facto standard : 사실상 표준

 

1 INTRODUCTION

Self-attention-based architectures, 특히 Transformers (Vaswani et al., 2017)는 NLP 에서 선택된 모델이 되었다. dominant approach은 large text corpus에 pre-train다음 더 작은 task-specific dataset (Devlin et al., 2019)에서 fine-tune 하는 것이다. (large data로 pre-train한다음 작은 data(필요한 작업에 대해서 )로 fine-tune한다.) Transformers’ computational efficiency and scalability 덕분에 100B 이상의 parameters (Brown et al., 2020; Lepikhin et al., 2020)를 사용하여 unprecedented size의 모델을 학습할 수 있게 되었다. models and datasets이 증가해도 performance이 saturating 상태를 이를 기미는 없다. 

하지만 , computer vision에서는 convolutional architectures가 지배적이다(LeCun et al., 1989; Krizhevsky et al., 2012; He et al., 2016) NLP successes의 영향을 받아 multiple works은 CNN과 유사한 architecture를 self-attention (Wang et al., 2018; Carion et al., 2020)와 결합하려고 시도하거나 , 일부 convolutions(Ramachandran et al., 2019; Wang et al., 2020a) 을 완전히 대체한다.  latter models은 이론적으로 효율적이지만  specialized attention patterns을 사용하기 때문에 modern hardware accelerators 에 대해서는 아직 효과적으로 확장되지 않았다. 따라서 large-scale image recognition에서 classic ResNet와 같은 architectures 은 여전히 state of the art (Mahajan et al., 2018; Xie et al., 2020; Kolesnikov et al., 2020)이다. 

NLP의 Transformer scaling 성공에서 영향을 받아 가능한 최소의 수정으로 images에 standard Transformer를 직접 적용하는 실험을 한다. 이를 위해, image를 patches 로 분할하고 Transformer에 대한 입력으로 이러한 patch의 linear embeddings sequence 를 제공한다. Image patches는 NLP application에서  tokens (words)과 동일한 방식으로 처리된다. 우리는 supervised fashion하는 방식으로 image classification에 대한 모델을 학습한다. 

  • image split to patch
  • Transformer의 input에 대한 patch의 linear embeddings sequence 를 제공

strong regularization없이 ImageNet과 같은 mid-sized datasets에 대해 학습한 경우, 이러한 모델은 비슷한 크기의 ResNet보다 몇 % point 더 낮은 정확도를 산출한다. 겉으로 보기에는 실망스러운 결과는 다음과 같다 : Transformers 는  translation equivariance and locality과 같이 cnn에 inherent 된 inductive biases을 일부 결여하고 있으므로 불충분한 양의 data에 대해 학습했을 떄 잘 일반화되지 않는다.

그러나 모델이 더 큰 datasets (14M-300M images)에 대해 학습된 경우 picture 이 변경된다. 우리는 대규모 학습이 inductive bias편견을 능가한다는 것을 발견했다. Vision Transformer (ViT)는 충분한 규모로 pre-trained하고 datapoints 수가 적은 tasks 으로 전송했을 떄 우수한 결과를 얻는다.  public ImageNet-21k dataset또는 in house JFT-300M dataset에 대해 pre-trained 을 받은 경우 ViT 는 multiple image recognition benchmarks에서 state of the art에 접근하거나 능가한다. 특히 best model은 ImageNet에서 88.55% ,  ImageNet-ReaL에서 90.72%, CIFAR-100에서 94.55%, VTAB suite of 19 tasks에서 77.63%의 정확도에 도달한다.

 

2 RELATED WORK

Transformers는 machine translation을 위해 Vaswani et al. (2017)에 의해 제안되었으며, 그 이후 많은 NLP 작업에서 state of the art이 되었다. Large Transformer-based models 은 종종 대형 corpora 에서 pre-trained 을 받은 다음  task at hand에 대해 fine-tuned한다. BERT (Devlin et al., 2019) 는 self-supervised pre-training task를 사용하는 반면 GPT 작업 line 은 pre-training task (Radford et al., 2018; 2019; Brown et al., 2020)로 language modeling을 사용한다. 

images 에 대한 self-attention을 적용하기 위해서는 각 픽셀이 다른 픽셀에 모두 집중해야 한다. pixels수의 2차 비용에서는 현실적인 input sizes로 확장되지 않는다. 그러므로 , image processing에서 transformer를 적용하기 이해 과거에 몇 가지 근사치가 시도되었다. Parmar et al. (2018) 은 globally이 아닌 각 query pixel에 대한 local neighborhoods에 만 self-attention를 적용했다. 이러한 local multi-head dot-product self attention blocks은 convolutions  (Hu et al., 2019; Ramachandran et al., 2019; Zhao et al., 2020)을 완전히 대체할 수 있다.  different line of work에서 Sparse Transformers (Child et al., 2019) 는 이미지에 적용하기 위해 glocal attention에 대한 확장 가능한 근사치를 사용한다. scale attention는 다른 방법은 individual axes (Ho et al., 2019; Wang et al., 2020a)을 따라 극단적인 경우에만 다양한 size (Weissenborn et al., 2019) blocks 으로 적용하는 것이다. 이러한 전문화된  attention architectures 중 다수는 computer vision tasks에서 유망한 결과를 보여주지만 hardware accelerators에서 복잡한 engineering을 효율적으로 구현해야 한다. 

우리와 가장 관견이 있는 model은 input image에서 2 × 2 size의 patches를 추출하고 위에 full self-attention 을 적용하는  Cordonnier et al. (2020) model이다. 이 모델은 ViT와 유사하지만, 우리의 연구는 large scale pre-training makes vanilla transformers competitive 를  (or even better than) state-of-the art CNNs 만든다는 것을 입증하기 위해 더 나아가고 있다. 또한  image classification (Bello et al., 2019) 를 위한 feature maps을 augmenting하거나 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) 과 같은 self-attention 를 사용하여 CNN의 output을 추가로 처리함으로써 convolutional neural networks (CNNs) 을 self-attentin 형태와 결합하는데 많은 관심이 있다. 

또 다른 최근 관련 model은 image resolution and color space을 줄인 후 image pixels에 Transformers을 적용하는 image GPT (iGPT) (Chen et al., 2020a)이다. 이 model은 generative model로 unsupervised fashion 방식으로 학습되며 , 그 결과  representation은 classification performance을 위해 fie-tuned 되거나 linearly으로 탐색되어 ImageNet에서 maximal accuracy of 72%를 달성할 수 있다. 

우리의 연구는 tandard ImageNet dataset 보다 더 큰 규모로 image recognition을 탐구하는 papers collection의 증가에 추가된다. additional data sources를 사용하면 standard benchmarks (Mahajan et al., 2018; Touvron et al., 2019; Xie et al., 2020) 에서 state-of-the-art 결과를 얻을 수 있다. 또한 Sun et al. (2017)은 dataset size에 따라 CNN이 어떻게 확장되는지, Kolesnikov et al. (2020); Djolonga et al. (2020) 는 ImageNet-21k and JFT-300M과 같은 large scale datasets 에서 CNN transfer learning에 대한 empirical exploration 수행하고 연구한다. two latter datasets 에도 초점을 맞추지만 prior works에서 사용된 ResNet-based models을 대신 Transformers를 학습한다. 

 

3 METHOD

 model design 에서 우리는 original Transformer (Vaswani et al., 2017)를 최대한 가깝게 따른다. 의도적으로 간단한 이 설정의 장점은 확장 가능한 NLP Transformer architectures 와 그 효율적인 구현이 거의 즉시 사용가능하다는 것이다. 

3.1 VISION TRANSFORMER (VIT)

model의 개요는 Figure 1에 설명되어 있다. standard Transformer 는 token embeddings의 1D sequence를 입력으로 받는다. 2D images을 처리하기 위해, 우리는 image x ∈ R ^(H×W×C ) 를 flattened 2D patches x_p ∈ R ^ {N×(P^2·C)}로 sequence 재구성한다. 여기서  (H, W) 는 original image의 resolution이고 , C는 number of channels이다. (P, P) 는 each image patch의 resolution이다. N = HW/P^2는 patch의 결과로 생성된 수이며 , 이는 Transformer의 effective input sequence length로도 사용된다. Transformer는 모든 layer를 통해  constant latent vector size D를 사용하기 때문에 우리는 학습 가능한 linear projection (Eq. 1)으로 flatten하게 하고 D dimensions으로 mapping한다.  

BERT’s [class] token과 유사하게(NSP next sentence prediction) ,우리는 학습 가능한 embedding을 Transformer encoder (z^0_L) ouput에서의 상태가  image representation y (Eq. 4)로 작동하는 embedded patches (z_0^0 = x_class)의 sequence에 추가한다. pre-training과 fine-tuning중에 classification head가 z^0_L에 부착된다.  classification head 는 pre-training 에 하나의 hidden layer가 있는 MLP와 fine-tuning time에  single linear layer 에 의해 구현된다. 

Position embeddings은 해당 위치 정보를 보존하기 이해  patch embeddings에 추가된다. advanced 2D-aware position embeddings (Appendix D.4)을 사용하여 상당한 향상을 관찰하지 못했기 때문에 학습 가능한 표준 1D position embeddings을 사용한다. embedding vectors 의 sequence결과는 encoder에 대한 입력 역할을 한다. 

Transformer encoder (Vaswani et al., 2017)는 multiheaded selfattention (MSA, see Appendix A) 과  MLP blocks (Eq. 2, 3). Layernorm (LN) 의 alternating layers로 구성된다. Layernorm (LN) 은 모든 block 앞에 적용되며 , 모든 block (Wang et al., 2019; Baevski & Auli, 2019) 뒤에 residual connections 부가 적용된다. 

MLP에는 GELU non-linearity을 가진  two layers가 포함되어 있다. 

 

 

 

 

Inductive bias. 우리는 Vision Transformer가 CNNs보다  image-specific inductive bias가 훨씬 적다는 점에 주목한다. CNNs에서는 locality(지역적), two-dimensional neighborhood structure및 translation equivariance이 전체 model에 걸쳐 각 층에 baked된다. ViT에서는 MLP layers만 local 및 translationally equivariant 반면 , self-attention layers은 global 이다. two dimensional neighborhood structures는 model 시작시 image를 patch로 cutting하고 다른 resolution의 image에 대한 position embeddings 을 조정하기 위해 fine-tuning time등 매우 드물게 사용된다. (아래 설명 참조 ) . 그외에는 초기화 시 position embeddings은 patches의 2D positions에 대한 정보를 제공하지 않으며 patch사이의 모든 공간 관계를 처음부터 학습할 필요가 없다. =>generation 문제  , position 으로 

Hybrid Architecture. raw image patches의 대안으로 , input sequence는 cnn(LeCun et al., 1989) 의 feature maps 에서 혈성될 수 있다.  hybrid model에서 , patch embedding projection E (Eq. 1) 는 CNN feature map에서 추출된 patch에 적용된다. 특별한 경우, patch 는 spatial size 1x1을 가질 수 있는데, 이는 input sequece가 feature map의 spatial dimensions 를 flattening하게 하고 Transformer dimension에 projecting함으로써 얻어짐을 의미한다. classification input embedding및 position embeddings 은 위에서 설명한 대로 추가된다. 

3.2 FINE-TUNING AND HIGHER RESOLUTION

일반적으로 ,  large datasets에서 ViT를 pre-train하고 (smaller) downstream tasks에 fine-tune한다(BERT).  이를 위해, 우리는  pre-trained prediction head를 제거하고 zero-initialized D × K feedforward layer를 부착한다. 여기서 K는 downstream classes의 수이다. 종종 pre-training (Touvron et al., 2019; Kolesnikov et al., 2020)보다 higher resolution으로 fine-tune  하는 것이 유익하다. higher resolution의 images 를 feeding할 때 patch size를 동일하게 유지하여 effective sequence length가 커진다. Vision Transformer 는 arbitrary sequence lengths (up to memory constraints)를 처리할 수 있지만 pre-trained position embeddings은 더 이상 의미가 없을 수 있다. 우리는 pre-trained position embeddings의 original image 내 위치에 따라 2D interpolation을 수행한다. 이 해상도 조정및 patch extraction은 영상의 2D구조에 대한 inductive bias이 Vision Transformer에 수동으로 주입되는 유일한 지점이다. 

 

 

4 EXPERIMENTS

ResNet, Vision Transformer (ViT) 및 hybrid 의 representation learning capabilities을 평가한다. 각 model의 요구사항을 이해하기 위해 다양한 size의 dataset를 pre-train하고 benchmark task를 평가한다. model pre-training의 computational 을 고려할 때 , ViT는 매우 우수한 성능을 발휘하여 낮은 pre-training cost으로 대부분의 ecognition benchmarks에서 state of the art을 달성한다. 마지막으로 , 우리는  self-supervision을 사용하여 작은 실험을 수행하고 self-supervised ViT가 미래에 대한 가능성을 가지고 있음을 보여준다. 

4.1 SETUP

Datasets. model scalability을 탐구하기 위해 1k classes와 1.3M images (we refer to it as ImageNet in what follows), 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를 사용한다.  Kolesnikov et al. (2020)에 이어 downstream tasks의 test sets를 사용하여 pre-training datasets를 de-duplicate한다. 이러한 dataset에 대해 학습된 모델을 여러 benchmark tasks에 transfer 한다. ImageNet   original validation labels 및  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). 이러한 datasets의 경우 pre processing는  Kolesnikov et al. (2020)을 따른다. 또한 19-task VTAB classification suite (Zhai et al., 2019b에서도 평가한다. VTAB 는 per task 1 000 training examples를 사용하여 다양한 task로의 low-data transfer을 평가한다. tasks 는 Natural – tasks like the above, Pets, CIFAR, etc. 세그룹으로 나뉜다. medical and satellite imagery -전문적인 및 Structured – task로 localization 와 같은 geometric understanding가 필요하다. Model Variants. Table1 에 요약된 것 처럼 BERT에 사용되는 (Devlin et al., 2019) ViT configurations을 기반으로 한다. “Base” and “Large” models은 BERT에서 직접 채택되었으며 우리는 더 큰 "Huge" 모델을 추가했다. 다음의 내용에서는 model size와 input patch size를 나타내기 위해 간단한 notation을 사용한다. 예를 들어 , ViT-L/16 은 16×16 input patch size를 가진 "Large" variant 을 의미한다. Transformer’s sequence lengths는 patch size의 square 에 proportional 하므로 patch size가 smaller 모델은 computationally이 더 많이 듭니다.

baseline CNNs의 경우  ResNet (He et al., 2016)을 사용하지만 Batch Normalization layers (Ioffe & Szegedy, 2015)을 Group Normalization (Wu & He, 2018)로 교체하고  standardized convolutions (Qiao et al., 2019)을 사용했다. 이러한 수정은 transfer (Kolesnikov et al., 2020)을 개선하며, 수정된 모델  “ResNet (BiT)”을 나타낸다. hybrids의 경우, intermediate feature maps을 하나의  “pixel” patch size로 ViT에 공급한다. different sequence lengths하기 위해 

 (i) regular ResNet50 의 4 stage  output을 취하거나 

(ii)  stage 4 제거, stage 3 (keeping the total number of layers)에 동일한 수의 layer batch 및 이 extended stage 2의 출력을 취한다. 

옵션 (ii)은 sequence length 가 4배 더 길어지고 ViT model은 더 비싸다. 

Training & Fine-tuning. 

batch size : 4096  Adam (Kingma & Ba, 2015) with β1 = 0.9, β2 = 0.999을 사용하여 ResNets를 포함한 모든 모델을 학습하고 , 

high weight decay of 0.1 -> 이는 모든 model의 transfer에 유용한 것으로 나타냈다(Appendix D.1은 일반적으로 practices과 대조적으로 ResNets에서 Adam이  SGD보다 약간 더 잘 작동하는 것을 보여준다. ). 우리는 linear learning rate warmup 과 decay를 사용한다. 자세한 내용은 Appendix B.1를 참조한다. fine-tuning의 경우 모든 model에 대해 momentum과 함께 SGD를 사용하고 , 

batch size : 512를 사용(Appendix B.1.1 참조)

 Table 2의 ImageNet results의 경우  ViT-L/16의 경우 512 및  ViT H/14의 경우 518의 resolution로 fine-tuned했으며 0.9999 (Ramachandran et al., 2019; Wang et al., 2020b) factor 로 Polyak & Juditsky (1992) 평균값을 사용했다. 

Metrics. few-shot 또는fine-tuning accuracy를 통해 downstream datasets에 대한 결과를 보고한다. Few-shot accuracies는 training images subset 의 (frozen) representation 을 

{−1, 1}^K target vectors에 mapping하는 regularized 된 least squares regression problem을 해결함으로써 얻어진다. 이 formulation 을 사용하면 exact solution을 closed form로 복구할 수 있다. 주로 ine-tuning performance에 focus을 맞추고 있지만  fine-tuning 비용이 너무 많이 드는 즉각즉인 evaluation를 위해 linear few-shot accuracies를 사용하기도 한다. 

4.2 COMPARISON TO STATE OF THE ART

우리는 먼저 가장 큰 모델 -  ViT-H/14 and ViT-L/16 을 논문의 state-of-the-art CNNs 과 비교한다. 

  1. 비교 point는 large ResNets로 supervised transfer learning 을 수행하는 Big Transfer (BiT) (Kolesnikov et al., 2020)이다.
  2. Noisy Student (Xie et al., 2020) 으로 , label이 제거된 상태에서 ImageNet 과 JFT300M  에 대한  semi-supervised learning  학습된 대규모 EfficientNet 이다. 현재 Noisy Student 는 여기에 보고된 다른 dataset 의 ImageNet and BiT-L the state of the art이다.

모든 mode은 TPUv3 hardware에 대해 학습을 받았으며, 각 모델을 pre-train 하는데 걸리는 TPUv3-core days,즉 학습에 사용되는 TPU v3 cores (2 per chip)를 일 단위로 곱한 값으로 보고한다. 

Table 2는 결고를 보여준다. JFT-300M 에서 pre-trained된 smaller ViT-L/16 model 은 모든 작업에서 BiT-L (which is pre-trained on the same dataset) 을 능가하는 동시에 학습에 필요한 computational resources 가 훨씬 더 적다. 더 큰 larger model,  ViT-H/14는 특히ImageNet, CIFAR 100, and the VTAB suite 등 challenging datasets에서 성능을 더욱 향상시킨다. 흥미롭게도, 이 모델은 여전히 이전의 state of the art보다 pre-train 하는데 훨씬 적은 compute 시간이 소요되었다. 그러나pre-training efficiency은 architecture choice 뿐만 아니라 training schedule, optimizer, weight decay, etc과 같은 다른 parameters에 의해 영향을 받을 수 있다는 점에 주목한다. Section 4.4에서 서로 다른 architecture에 대한 performance vs. compute 에 대한 통제된 연구를 제공한다. 마지막으로 public ImageNet 21k dataset에서  pre-trained  ViT-L/16 model은 대부분의 데이터 세트에서도 우수한 성능을 발휘하는 동시에 사전 학습에 필요한 dataset에서도 우수한 성능을 발휘하는 동시에 사전 학습에 필요한 resource를 적제 사용한다. 약 30 days내에 8개의 cores가 있는 standard cloud TPUv3 를 사용하여 학습할 수 있다. 

Figure 2 는 VTAB 작업을 각각의 group으로 나누고, ImageNet과 Youtube(Tschannen et al., 2020)  에서 co-trained 한 ResNet 및 S4L – supervised plus semi-supervised learning on ImageNet (Zhai et al., 2019a) 의 previous SOTA methods 과 비교한다. ViT-H/14 는 Natural and Structured tasks에서 BiT R152x4 및 기타 방법을 능가한다. Specialized 에서 top two models 의 성능은 비슷하다. 

4.3 PRE-TRAINING DATA REQUIREMENTS

Vision Transformer는 arge JFT-300M dataset에서 pre-trained했을 때 성능이 우수하다. ResNets보다 vision에 대한 inductive biase이 적은 경우 dataset size가 얼마나 중요 합니까? 우리는 two series 의 실험을 수행한다.

  1. ViT models 을 size가 증가하는 dataset에 pre-train을 한다. ImageNet, ImageNet-21k, and JFT300M. 더 작은 datasets에서 성능을 향상 시키기 위해 weight decay, dropout, and label smoothing 이라는 세가지 basic regularization parameters를 최적화 한다. Figure 3 은 ImageNet (results on other datasets are shown in Table 5) finetuning  한 후의 결과이다. 가장 작은 dataset에 대한 pre-trained을 받은 mageNet, ViT-Large models은 regularization(moderate)에도 불구하고 ViT-Base models에 비해 성능이 떨어진다. ImageNet-21k pre-trainin으로 , 그들의 성능은 비슷하다. JFT-300M에서만 larger models의 이점을 충분히 누릴 수 있다. Figure 3으 또한 다양한 크기의 BiT 모델에 의해 확장된 성능 영역을 보여준다. BiT CNNs은 ImageNet에서 ViT를 능가하지만 dataset가 클수록 ViT를 능가한다. 
  2. 9M, 30M, and 90M 의 random subsets 과 full JFT300M dataset에 대해 모델을 학습한다. smaller subsets 에 대해 additional regularization를 수행하지 않으며 모든 설정에 동일한 hyper-parameters를 사용한다. 이러한 방식으로 regularization의 효과가 아닌  intrinsic model properties을 평가한다. 그러나 early-stopping을 사용하고 학습 중에 달성한 최고의 검증 정확도를 보고한다. 컴퓨팅을 절약하기 위해 full finetuning accuracy 대신  few-shot linear accuracy를 보고한다. Figure 4 는 결과를 나타낸다. Vision Transformers는 소규모 datasets에서 비슷한 계산 비용으로 ResNet보다 더 많이 적합하다.예를 들어 , ViT-B/32는 ResNet50보다 약간 빠르다. 9M subset에서는 성능이 훨씬 떨어지지만 90M+ subsets에서는 더 우수하다. ResNet152x2 and ViT-L/16도 마찬가지이다. 이 결과는 convolutional inductive bias가 너무 작은 datasets에 유용하다는 직관을 강화하지만 , 더 큰 dataset의 경우 데이터에서 직접 관련 pattern을 학습하는 것으로 충분하고 심지어 유익하다. 

Note that the ImageNet pre-trained models are also fine-tuned, but again on ImageNet. This is because the resolution increase during fine-tuning improves the performance. => ImageNet pre-trained models are도 ImageNet에서 fine-tuned된다. fine-tuning 중 에 resolution 가 높아지면 향상되기 때문이다. 

 

전반적으로 ImageNet (Figure 4)의 few-shot 결과와  VTAB (Table 2)의 low-data 결과는 매우 낮은 data 전송에 대해 유망해 보인다. ViT의 few-sho properties에 대한 추가 분석은 향후 작업의 흥미로운 방향이다. 

 

 

 

4.4 SCALING STUDY

우리는 JFT-300M의 전송 성능을 평가하여 다양한 모델에 대한 제어된 sacling 연구를 수행한다. 이 설정에서 data size는 model의 성능에 bottleneck 현상을 일으키지 않으며, 각 model의 성능 대 pre-training cost을 평가한다. model set에는 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, pretrained for 7 epochs, plus L/16 and H/14 pre-trained for  4 epochs; 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 (hybrids의 경우, model 이름 끝에 있는 숫자는 patch size가 아니라 ResNet Backbone의 총 sampling 비율을 나타낸다. ) 

Figure 5는 총 pre-traing compute(계산 비용에 대한 자세한 내용은  Appendix D.5 참조). model 별 세부 결과는 몇 가지 패턴을 관찰할 수 있는 Appendix. A Table 6 에 제공된다. 

첫째 ,Vision Transformers 가 performance/compute trade-off를 통해 ResNet을 지배한다. ViT의 동일한 성능 (평균 5개 이상의 dataset)을 달성하기 위해 약 2-4 배 적은 compute을 사용한다. 

두번째, hybrids는 적은 계산으로 ViT를 약간 능가하지만 대형 model에서는 그 차이가 사라진다. 이 결과는 다소 놀랍다. 어떤 size에서도 ViT를 지원할 수 있는 convolutional local featrue  processing가 예상될 수 있기 때문이다. 

셋쨰, Vision Transformers는 시도한 범위내에서 saturate 상태가 아닌것으로 보여 향후 scaling efforts에 동기를 부여한다. 

4.5 INSPECTING VISION TRANSFORMER

Vision Transformer가 이미지 data를 처리하는 방법을 이해하기 위해  internal representations을 분석한다. Vision Transformer 의 첫번째 layer는 lower-dimensional space (Eq. 1)에  linearly projects한다. Figure 7 (left) 은 learned embedding filters의 top principal compenents 를 나타낸다. components 는 가 patch 내의 fine structure의 low dimensional representation을 위한 그럴듯한 기본 기능과 유사하다. 

투영 후 학습된 position embedding이 patch representation에 추가된다. Figure 7 (center) 은 모델이 position embedding의 유사성으로 이미지 내 거리를 encoding 하는 방법을 학습한다는 것을 보여준다. 즉 더 가까운 patch는 position embedding이 더 유사한 경향이 있다. 또한 row-column structure가 나나난다. 동일한 row/column 에 있는 patch에 유사한 embedding이 있다. 마지막으로 , sinusoidal structure는 떄때로 더 큰 grids(Appendix D) 에서 명백하다.  position embeddings이 2D image topology 를 나타내는 방법을 배운다는 것은 수작업으로 만들어진 2D 인식 embedding 변형이 개선(Appendix D.4)을 산출하지 못하는 이유를 설명한다. 

ViT는 Self-attention을 통해 가장 낮은 layer에서도 전체 이미지에 걸쳐 정보를 통합할 수 있다. 우리는 network 가 이 기능을 어느 정도 사용하는지 조사한다. 특히 attention weights (Figure , right) 를 기준으로 정보가 통합되는 이미지 공간의 평균 거리를 계산한다. 이 “attention distance”는 CNN의  receptive field size 와 유사하다. 우리는 몇몇 head가 이미 가장 낮은 계층에 있는 대부분의 이미지에 주의를 기울이는 것을 발견했는데, 이는 전 세계적으로 정보를 통합하는 기능이 실제로 모델에 사용되고 있음을 보여준다. 다른 attention  head는 lower layer에서 attention distances가 지속적으로 작다. 이러한 highly localized attention는 Transformer (Figure 7, right) 이전에 ResNet을 적용하는 hybrid model에서는 덜 두드러지며, 이는 CNN 초기 convolutional  layer와 유사한 기능을 제공할 수 있음을 시사한다. 또한 , attention distance는 network depth에 따라 증가한다. 전체적으로 , model이 classification (Figure 6)와 의미적으로 관련이 있는 이미지 영역에 해당하는 것을 발견했다. 

 

4.6 SELF-SUPERVISION

Transformers는 NLP task에서 인상적인 성능을 보여준다. 그러나  이러한 성공의 대부분은 뛰어난 확장선 뿐만 아니라 대규모 elf-supervised pre training (Devlin et al., 2019; Radford et al., 2018)에서 비롯한다.우리는 또한 BERT에 사용되는  masked language modeling task 을 모방하여 self supervision을 위한 maskted patch prediction에 대한 예비 탐사를 수행한다. self-supervised pre-training을 통해 , smaller ViT-B/16 model 은 ImageNet에서 79.9% accuracy를 달성하여 처음부터 2%의 대폭 향상되었지만 supervised pre-training에는 여전히 4% 뒤처져 있다. Appendix B.1.2에는 자세한 내용이 포함되어 있다. contrastive pre-training (Chen et al., 2020b; He et al., 2020; Bachman et al., 2019; Henaff et al., 2020)에 대한 탐구는 미래 작업에 맡긴다. 

5 CONCLUSION

image recognition에 Transformers 를 직접 적용하는 방법에 대해 알아봤다. computer vision에 self-attention 를 사용한 이전 작업과 달리 , initial patch extraction step와 는 별도로 image-specific inductive biases 을 arichitecture에 도입하지 않는다. 대신에 image patches를 sequence로 해석하고 NLP에서 사용되는 standard Transformer encoder에 의해 처리한다. 이는 단순하지만 scalable 전력은 대규모 datasets에 대한 pre-training 과 결합했을 때 놀라울 정도로 잘 작동한다. 따라서 Vision Transformer는 많은 image classification datasets에서 최신 기술과 일치 하거나 이를 초과하지만 pre-train은 상대적으로 저렴하다. 

이러한 initial results는 encouraging만 , 여전히 많은 challenges 가 남아있다. 

1. ViT 를 detection and segmentation과 같은 다른 computer vision tasks에 적용하는 것이다. 우리의 결과는 Carion et al. (2020)의 결과와 결합되어 이 접근 방식의 가능성을 나타낸다. 

2. elfsupervised pre-training methods을 게속 탐구하는 것이다. 우리의 initial experiments은 self-supervised pre-training보다 개선 되었음을 보여주지만, self-supervised and large-scale supervised pretraining 사이에는 여전히 큰 차이가 있다. 

ViT 의 further scaling 으로 인해 성능이 향상될 가능성이 높다. 

 

 

APPENDIX

A MULTIHEAD SELF-ATTENTION

Standard qkv self-attention (SA, Vaswani et al. (2017))

Multihead self-attention (MSA) is an extension of SA in which we run k self-attention operations, called “heads”, in parallel, and project their concatenated outputs.

 

B EXPERIMENT DETAILS

B.1 TRAINING

B.1.1 FINE-TUNING

384 resolution

B.1.2 SELF-SUPERVISION

 

C ADDITIONAL RESULTS

 

D ADDITIONAL ANALYSES

D.1 SGD VS. ADAM FOR RESNETS

D.2 TRANSFORMER SHAPE

D.3 HEAD TYPE AND C L A S S TOKEN

D.4 POSITIONAL EMBEDDING

D.5 EMPIRICAL COMPUTATIONAL COSTS

D.6 AXIAL ATTENTION

D.7 ATTENTION DISTANCE

D.8 ATTENTION MAPS

D.9 OBJECTNET RESULTS

D.10 VTAB BREAKDOWN

 

출처 : AN IMAGE IS WORTH 16X16 WORDS:TRANSFORMERS FOR IMAGE RECOGNITION AT SCALE

파파고 번역을 많이 참조했다. 

반응형

+ Recent posts