반응형

논문 

Mingxing Tan 1 Quoc V. Le 1

Abstract

model scaling을 체계적으로 연구하고 network depth, width, and resolution 을 조정하여 성능 향상

a new scaling method → uniformly scales all dimensions of depth/width/resolution using a simple yet highly effective compound coefficient.

EfficientNets

소스 코드 : https://github.com/tensorflow/tpu/tree/master/models/official/efficientnet

1. Introduction/2. Related Work

depth more layer ResNet, VGG
width channel의 개수 Wider Residual Networks, MobileNets
image resolution input image의 resolution을 키움 Gpipe

compound scaling method

효과적인 이유 : input image is bigger → the network needs more layer to increase the receptive field and more channels to capture more fine-grained patterns on the bigger image.

3. Compound Model Scaling

3.1. Problem Formulation

3.2. Scaling Dimensions

Depth (d): 자주 사용하는 방식

depth 를 깊이 할 경우 high level의 feature를 뽑을 수 있고 generalize 잘 되고 성능이 올라간다

하지만 어느 정도 까지 갈 경우 saturate 상태가 된다.

The intuition is that deeper ConvNet can capture richer and more complex features, and generalize well on new tasks.

하지만 , networks 가 깊어지면 깊어질수록 학습하기 어렵고 vanishing gradient problem이 있다.

skip connection, batch normalization 으로 학습 문제를 완화하지만 매우 깊은 network의 정확도 이득은 감소한다. 예를 들어 ResNet-1000은 ResNet-101 비슷한 정확도를 가진다.

width(w) : small size models에 자주 사용

fine-grained features 쉽게 뽑아내고 train을 쉬운 경향이 있다.

channel을 널리면 network depth를 줄이기 때문에 higher level features이 덜 얻게 되는 문제가 있을 수 있다.

Resolution (r): capture more fine-grained patterns

Resolution  
224x224 early ConvNets
299x299 Rethinking the inception architecture for computer vision
331X331 Learning transferable architectures for scalable image recognition. CVPR, 2018. NasNet
480x480 Gpipe: Efficient training of giant neural networks using pipeline parallelism.
600x600 Mask-RCNN, FPN

너무 크면 정확도도 떨어지고 계산량도 많아진다.

위의 그림을 보시면 width scaling, depth scaling 은 비교적 이른 시점에 정확도가 saturation 되며 그나마 resolution scaling이 키우면 키울수록 정확도가 잘 오르는 것을 확인할 수 있다.

Observation 1 – 네트워크의 width, depth, resolution 중 어느 차원을 scale up 시켜도 성능은 향상된다. 그러나 너무 큰 모델에 있어서는 그 성능 향상이 saturate된다.

3.3. Compound Scaling

직관적으로 생각해보면 Input image가 커지면 그에 따라서 receptive field도 늘려줘야 하고 더 많은 layer가 필요하고 , resolution 이 커져서 특징들을 뽑아낼려면 더 많은 channel이 필요한 것

resolution 키우면 그것에 맞게 depth와 width도 키워야 될 것이다.

Observation 2 –성능과 효율성을 높이기 위해서 ConvNet scaling을 진행할 때, width, depth, resolution의 모든 차원의 밸런스를 맞추는게 중요하다.

compound scaling method

4. EfficientNet Architecture

MnasNet과 비슷한데 latency가 들어있지 않는다.

5. Experiments

5.1. Scaling Up MobileNets and ResNet

기존에 존재한 모델 baseline, depth, width, resolution, compound scale를 변경하여 하였지만 그중에서 compound scale의 정확도가 높았다.

5.2. ImageNet Results for EfficientNet

MnasNet: Platform-aware neural architecture search for mobile. CVPR, 2019 RMSProp optimizer with decay 0.9 and momentum 0.9 batch norm momentum 0.99 weight decay $1e^{-5}$ initial learning rate 0.256 that decays by 0.97 every 2.4 epochs SiLU (Swish-1) activation AutoAugment stochastic depth (Huang et al., 2016) with survival probability 0.8 As commonly known that bigger models need more regularization, we linearly increase dropout (Srivastava et al., 2014) ratio from 0.2 for EfficientNet-B0 to 0.5 for B7.

Table 2

정확도는 비슷하지만 parameter 수와 FLOPS수 가 적다.

parameters-accuracy and FLOPS-accuracy

our EfficientNet models are not only small, but also computational cheaper.

latency을 검증하기 위해 inference latency 도 측정 → Table 4

5.3. Transfer Learning Results for EfficientNet

Table 5 shows the transfer learning performance:

(1) Compared to public available models, such as NASNet-A (Zoph et al., 2018) and Inception-v4 (Szegedy et al., 2017),

(2) Compared to stateof-the-art models, including DAT (Ngiam et al., 2018) that dynamically synthesizes training data and GPipe (Huang et al., 2018)

Figure 6 compares the accuracy-parameters curve for a variety of models.

6. Discussion

Figure 8 Compound scaling에서 2.5%

Figure 7 class activation map (Zhou et al., 2016),

해당 통계는 Table 7에서 보여준다.

Images는 random으로 ImageNet validation set에서 선택되였다.

Figure 7에서 볼 수 있듯이 compound scaling 이 있는 model은 object details 정보가 더 많은 관련 region에 focus을 맞추는 경향이 있는 반면, 다른 models은 object details 정보가 부족하거나 이미지의 모든 objects를 capture 할 수 없다.

반응형
반응형

https://arxiv.org/abs/1804.02767?fbclid=IwAR3A2nyK8EPa-JcoGp_N6tNqVkKOmy2J1ip5AYcEki5FzkZ62E3z6tbNSy0

 

YOLOv3: An Incremental Improvement

We present some updates to YOLO! We made a bunch of little design changes to make it better. We also trained this new network that's pretty swell. It's a little bigger than last time but more accurate. It's still fast though, don't worry. At 320x320 YOLOv3

arxiv.org

 

코드 : 

https://pjreddie.com/darknet/yolo/

 

YOLO: Real-Time Object Detection

YOLO: Real-Time Object Detection You only look once (YOLO) is a state-of-the-art, real-time object detection system. On a Pascal Titan X it processes images at 30 FPS and has a mAP of 57.9% on COCO test-dev. Comparison to Other Detectors YOLOv3 is extremel

pjreddie.com

Abstract

약간의 디자인 change를 했고 → 성능 , 속도를 향상 ⇒ ideas from other people

new network that’s pretty swell.

320 x 320 YOLOv3 runs in 22ms at 28.2 mAP, as accurate as SSD but three times faster.

코드 : https://pjreddie.com/darknet/yolo/

1. Introduction

YOLOV3

 

2. The Deal

2.1. Bounding Box Prediction

YOLO9000 bounding box를 예측하는데 dimension clusters anchor boxes로 사용한다.

4 coordinates for each bounding box

loss : sum of squared error loss

predicts an objectness score for each bounding box using logistic regression

threshold of .5

Faster RCCN과 달리 우리 시스템은 각 ground truth object 에 대해 하나의 bounding box를 할당한다.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

2.2. Class Prediction

multilabel classification를 사용하여 bounding box에 포함될 수 있는 class를 예측한다.

softmax를 상요하지 않고 대신 단순한 independent logistic classifiers를 사용한다. softmax를 사용하면 각 bounding box가 겹치는 레이블이 많을 경우 잘 안된다.

학습하는 동안 class predictions 을 위해 binary cross entropy loss을 사용한다.

A multilabel approach better models the data. ⇒ 겹치는 label에 대하여

 

2.3. Predictions Across Scales

boxes는 3가지 다른 scale에 대해서 예측한다.

we predict 3 boxes at each scale so the tensor is N × N × [3 ∗ (4 + 1 + 80)] for the 4 bounding box offsets, 1 objectness prediction, and 80 class predictions.

다음으로 우리는 previous layer 2개에서 feature map을 가져와 2x upsample 한다. 또한 network의 초기에서 feature map을 가져와 연결을 사용하여 upsampled 된 feature와 concatenation한다. ⇒ 이 방법을 사용하여 upsampled feature에서 더 의미 있는 의미 정보를 얻고 이전 feature map에서 더 세분화된 정보를 얻을 수 있다.

Feature Pyramid Network

We then add a few more convolutional layers to process this combined feature map, and eventually predict a similar tensor, although now twice the size.

COCO dataset the 9 clusters were: (10×13),(16×30),(33×23),(30×61),(62×45),(59×119),(116 × 90),(156 × 198),(373 × 326).

 

2.4. Feature Extractor

hybrid approach between the network used in YOLOv2, Darknet-19, and that newfangled residual network stuff

successive 3 × 3 and 1 × 1 convolutional layers but now has some shortcut connections

Darknet-53

 

 

2.5. Training

full image

multi-scale training, lots of data augmentation, batch normalization, all the standard stuff.

Darknet neural network framework for training and testing

 

3. How We Do

 

4. Things We Tried That Didn’t Work

Anchor box x, y offset predictions.

normal anchor box prediction mechanism ⇒ model stability를 감소시키고 잘 작동하지 않는다는 것을 발견

Linear x, y predictions instead of logistic.

linear activation to directly predict the x, y offset instead of the logistic activation ⇒ drop mAP

Focal loss.

dropped our mAP about 2 points. YOLOv3은 별도의 objectness predictions과 conditional class predictions 을 가지고 있기 때문에 focal loss 해결하려는 문제에 이미 강력하다.

Dual IOU thresholds and truth assignment.

Faster RCNN uses two IOU thresholds during training. ⇒ couldn’t get good results.

 

 

 

구글 번역기 참조 하였다. 

반응형
반응형

CDistNet: Perceiving Multi-Domain Character Distance for Robust Text Recognition

 

https://arxiv.org/abs/2111.11011

 

CDistNet: Perceiving Multi-Domain Character Distance for Robust Text Recognition

The attention-based encoder-decoder framework is becoming popular in scene text recognition, largely due to its superiority in integrating recognition clues from both visual and semantic domains. However, recent studies show the two clues might be misalign

arxiv.org

Abstract

attention-based encoder-decoder framework는 scene text recognition에서 인기가 있는 이유는 visual and semantic domains으로 부터 recognition clues(힌트)를 통합하는데 있어서 성능이 우월하다. ⇒ scene text recognition 의 trend이다.

하지만 최근의 연구는 visual and semantic 양쪽의 clues가 특히 어려운 text에서 서로 잘 연결이 안되고 그것을 완화하기 위해서 character position constraints 을 소개한다. ⇒ 한계점

어떤한 성공에도 불구하고 의미 있는 지역적인 image regions와 a content-free positional embedding은 거의 안정적으로 연결되지 않는다.

이 논문은 visual and semantic related position encoding 새로운 모듈을 소개 ⇒ Multi-Domain Character Distance Perception (MDCDP)이라고 하는 모듈

MDCDP는 attention mechanism에 따라 visual and semantic features 두개 다 query로 사용하기 위해 positional embedding을 사용한다.

visual and semantic distances 를 모두 설명하는 positional clue를 자연스럽게 encoding한다.

우리는 새로운 architecture CDistNet이라고 하고 MDCDP를 여러개 쌓은 것 이며 좀 더 정확한 distance modeling이 가능하다.

따라서 다양한 어려움이 제시되더라도 visual-semantic alignment 이 잘 구축된다.

two augmented datasets and six public benchmarks

시각화는 또한 CDistNet이 visual and semantic domains 모두 에서 적절한 attention localization를 달성함을 보여준다.

소스코드 위치 : https://github.com/ simplify23/CDistNet. 소스코드는 초반에 없었는데 공개되였다.

 

1. Introduction

최근 몇년 동안 엄청나는 많은 연구가 수행되었음에도 Scene text recognition은 여러가지 문제에 직면해있다. 예를 들어, complex text deformations, unequally distributed characters, cluttered background, etc. ⇒ key issue

최근에는 attention-based encoder-decoder methods가 이 task에서 인상적인 영향을 보여왔다.

하지만 최근 연구[38]에서 는 두가지 잘못 인식된 예와 같이 흔치 않는 정형화 되지 않는 text에서 mismatch가 쉽게 일어난다. Fig.1 (a)참조 .

선행 연구에서 mismatch 발생한 원인

1). visual clue가 약할 때 visual counterpart에 대해서 semantic clue가 제대로 찾지 못한다.

2). 길이가 long text에서 많이 일어난다. text 길이가 길면 semantic feature가 점점 강화되면서 완전히 압도가 된다.

⇒ attention drift

위의 문제로 , mismatch를 완화하기 위하여 character position을 사용하여 연구를 진행한다 . sinusoidal-like positional embedding [6,29] or others [35,43,44]으로 encoding하였다.

이런 전략으로 문제는 좀 해결할 수 있으지만 [29, 44]여기에서는 content-free positional embedding을 사용하였기 때문에 visual feature가 character position하고 안정적으로 연관짓기가 어려웠다. 게다가 이미지 위치에 대한 character position에 대한 위치도 정해놓지 못하고 content-free positional embedding이 오히려 position order에 대한 제약만 주었다.

content-aware receptor를 해서 인식하는 것이 아니라 position order에 대한 제안만 주었다.

게다가 position and semantic space 관계는 아예 무시를 해버린다.

 

이 논문에서는 앞에서 언급된 이슈들을 극복하기 위해서 Multi Domain Character Distance Perception (MDCDP) 이라고 하는 새로운 module을 개발하였다.

기존의 연구 [34, 44] 와 유사하게 fixed positional embedding이 초기화 된다.

하지만 다른 점은 encoder가 position embedding하고 나서 그리고 visual and semantic features가 self-attention enhancement를 걸친다. 그리고 나서 비로서 query vector로 사용이 된다.

two enhanced features가 일종의 visual and semantic distance-aware representation 이 된다.

이전 정보 가 다음 MDCDP의 query vector로 들어간다. 그렇게 하면 좀 더 attention-focused visual-semantic alignment 가 얻어진다.

이런 idea를 따라서 CDistNet이라는 architecture를 제안한다.

여러개 MDCDP가 쌓인 것이고 정확한 distance modeling이 가능하도록 한다.

이렇게 하면 complex character이 spatial layouts 이 인식하는데 도움이 된다.

(b) HA-IC13 and CA-IC13 datasets are created by horizontal and curved stretching ICDAR2013 with various scales.

(c) We develop CDistNet that perceives multi-domain character distance better by position-related joint encoding. Compared with baseline, the accuracy margin becomes larger as the deformation severity rises.

 

 

3가지 기여도가 이다.

  1. MDCDP visual and semantic features모두 positional feature 를 사용 할 수 있게 만든다.
  2. CDistNet stacks several MDCDP 어려운 text를 recognizing하는데 이점이 있다.
  3. we carry out extensive experiments with different configurations and compare CDistNet with existing methods.

2. Related Work

2.1. Semantic-free Methods

RNN and CTC loss

semantic정보를 무시 하고

visual feature만 가지고 modeling한다.

2.2. Semantic-Enhanced Methods

visual feature을 강화하기 위해 semantic clue를 활용하고 attention framework와 함께 encoder decoder를 사용하는 것을 강조

Transformer [34], a powerful model in capturing global spatial dependence, many variants [23, 29, 37] were developed with improved accuracy.

semantic loss를 도입한 것도 있고

semantic feature를 사용하는데 visual feature를 강화하는

ABINet은 별도의 language model을 사용하고 나중에 합쳐서 사용

하지만 misalignment문제가 여전히 남아 있고 attention drift

2.3. Position-Enhanced Methods

position도 고려하겠다.

character position encoding to ease the recognition

advanced rectification models 개발하였지만 , rectification 자체로는 서로 different clues에서 synergistic사용하는데 실패하였다.

Transformer-based models attention mechanism was non-local global하게 한다.

sinusoidal positional embedding

learnable embedding

segmentation map : ensure that characters

RobustScanner [44] proposed a position enhancement branch along with a dynamical fusion mechanism and achieved impressive results.

RobustScanner content-free positional embedding that hardly built a stable correspondence between positions and local image regions

CDistNet에서는 positional embedding을 visual and semantic features 양족에다 주입해서 multi-domain distance aware modeling 수립

 

3. Methodology

end-to-end trainable network

attention-based encoder-decoder framework

encoder : three branches : encoding visual, positional and semantic information

decoder : three kinds of information are fused by a dedicated designed MDCDP module, positional branch is leveraged to reinforce both visual and semantic branches and generate a new hybrid distance-aware positional embedding.

The generated embedding, which records the relationship among characters in both visual and semantic domains, is used as the positional embedding of the next MDCDP. (다음 MDCDP input으로 사용)

It is thus conducive to generating a attention-focused visual-semantic alignment.

The MDCDP module is stacked several times in CDistNet to achieve a more precise distance modeling.

At last, characters are decoded sequentially based on the output of the last MDCDP module.

마지막 MDCDP module의 output이 문자를 순차적으로 decoding된다.

3.1. Encoder

Visual Branch. TPS를 사용해서 rectify 을 먼저 한다.

Backbone : ResNet-45 and Transformer units , both local and global spatial dependencies를 captures 한다.

ResNet45

Transformer units are three-layer self-attention encoders with 1024 hidden units per layer

T : TPS block

R represents ResNet-45, ResNet-45 downsamples both the width and height to 1/8 of the original size

τ is the Transformer unit

Semantic Branch.

previously seen characters during training

이전에 decode된 character들이 input으로 들어간다.

test 단계에서, 이전에 decode된 character들은 각 time step에서 update되는 current semantic feature으로 encode된다.

Embedding of the start token is used when decoding the first character.

L을 decoding할려고 하면 input은 없으면 안되서 start token으로 한다.

Positional Branch.

text의 문자 위치를 endode한다.

먼저 one-hot vector로 만든다. → same sinusoidal positional embedding

 

3.2. MDCDP

MDCDP module is formulated on the decoder side and benefit the recognition

3가지 parts로 구성이 되여있다.

self-attention enhancement for positional feature reinforcement

cross-branch interaction that utilizes positional feature to query both the visual and semantic branches, obtaining positional-enhanced representations

dynamic shared fusion to get a visual and semantic joint embedding

Self-Attention Enhancement (SAE)

encoder에서 positional embedding을 주면 SAE 가지고 embedding을 강화한다. multi-head self-attention block한개인 vanilla Transformer에서 다 빼고 하나인 것을 하고 self-attention을 한다.

dimension도 줄였다.

이 방식은 upper triangular mask 이고 

반대로 된 것은 lower triangular mask이다.

 

np.triu() ⇒ upper triangular mask : mask is applied to the query vector of the self-attention block to prevent from ”seeing itself”, or saying, leaking information across time steps. 다음 정보는 보면 안된다.

np.tril() ⇒ lowertriangular mask

 

RobustScanner내용

before using the positional embedding to query the visual feature 이러한 enhancement 는 사용하지 않는다. The query vector is always fixed in different character sequences. 바뀐 것이 없다.

반면에 , our enhancement enables a more targeted positional embedding learning.

Cross-Branch Interaction (CBI)

positional embedding is treated as the query vector

visual and semantic branches in parallel

When applying to the visual branch, it uses previous decoded character locations to search the position of the next character in the text image. CBI-V

While applying to the semantic branch, it models the semantic affinities between previous decoded characters and current positional clue. CBI-S.

Both branches have been reinforced after the interactions.

A similar upper triangular mask is also applied to the semantic branch to prevent information leaks due to its dynamical update nature.

이전 연구에서는 semantic feature가 query 로 들어가고

RobustScanner position에서 추가적인 query를 visual 쪽에 다 query를 얻은 것이다. position to visual and enables a positional-enhanced decoding.

하지만 , 우리는 semantic branch는 그대로 둔다. 대조적으로, we formulate the interactions as the positional-based intermediate enhancement to both visual and semantic domains. It reinforces not only visual but also semantic features and can be understood as delineating the multi-domain character distance.

Dynamic Shared Fusion (DSF).

two positional-enhanced features as input

visual 과 semantic

channel방향으로 concatenated 해서 하는데 channel이 2배가 된 hybrid feature가 된다.

→ 그 다음 다시 1 × 1 convolution 을 해서 절반으로 줄인다.

→ 그 다음 gating mechanism을 사용 transformed weight matrices

→ both visual and semantic features element-wisely

→ dynamic fusion

ABINet 

 

 

channel이 2C였다가 C로 줄어든다.

특이한 점은 the weights are shared among different MDCDP modules. As a consequence, DSF not only decouples the feature fusion with the previous attention learning, but also eases the network modeling.

 

4. Experiments

4.1. Datasets

three kinds of datasets :

two synthetic datasets for model training MJSynth (MJ) [10] and SynthText (ST) [7]

데이터 셋 sample

https://arxiv.org/pdf/1904.01906.pdf

two augmented datasets for model verification

HA-IC13 and CA-IC13 two augmented datasets created from ICDAR2013

simulate the horizontal (HAIC13) and curved (CA-IC13) stretching with scales from 1 (the smallest deformation) to 6 (the largest deformation) with interval of 1 using the data augmentation tool in [21]

postprocessing exception 것을 처리 하기 위한 것

6배 정도 많다.

six widely used public datasets for both ablation study and comparison with existing methods.

ICDAR2013 (IC13) [13], Street View Text (SVT) [36], IIIT5k-Words (IIIT5k) [24], ICDAR2015 (IC15) [12], SVT-Perspective (SVTP) [26] and CUTE80 (CUTE) [28]

The first three mainly contain regular text while the rest three are irregular.

4.2. Implementation details

We resize the input images to 32×128 and employ data augmentation such as image quality deterioration, color jitter and geometry transformation.

 Transformer 확인 

transformer의 learning rate와 같다.

To reduce the computational cost, we shrink the transformer units employed, where dimension of the MLP layer is reduced from 2048 to 1024 in encoder, and from 2048 to 512 in decoder.

beam search

4.3. Ablation study

 

 

 

 

The number of MDCDP modules considered.

layer를 많이 쌓으면 쌓을 수록 computational cost가 증가한다.

Therefore the MDCDP modules in CDistNet are empirically set to 3.

The effectiveness of SAE.

self attention enhancement는 position branch 에 사용

The effectiveness of CBI.

The result basically validates two hypotheses.

First, imposing the positional clue is helpful.

Second, it is effective to query the semantic feature by using the positional clue, which perceives the semantic affinities between previous decoded characters and current position.

The effectiveness of DSF.

DSF outperforms static-based fusions (Add and Dot) as well as the scheme that not sharing weights among MDCDP modules.

 

 

 

 

 

 

 

 

4.4. Model Verification

Contribution of the positional utilization.

We first explain how the methods are modified.

CDistNet w/o Sem

Transformer* visual branch를 강화

RobustScanner* Transformer unit to replace the raw ”CNN+LSTM” implementation

CDistNet

With the modifications above, accuracy

gains from the position modeling can be quantitatively evaluated.

positional utilization이 중요

Performance on augmented datasets.

HAIC13 and CA-IC13 are simulated with different levels of horizontal and curved deformations.

It clearly verifies the advantage of CDistNet in recognizing difficult text.

Decoding Visualization.

attention map based on the positional-enhanced visual branch and give some examples in Fig.6

It again indicates the superiority of the proposed MDCDP module.

 

 

 

 

 

semantic affinities between previous decoded characters and current position in Fig.7

Analysis of good and bad cases.

good: we can conclude that CDistNet retains powerful and universal recognition capability with the existence of various difficulties, e.g., diverse text shapes, blur, distortions, etc.

bad : We also list some bad cases in Fig.9. The failures can be summarized as three categories mainly, multiple text fonts (cocacola, quilts), severe blur (coffee) and vertical text (garage). Most of them are even undistinguishable by humans and they are common challenges for modern text recognizers.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

4.5. Comparisons with Existing Methods

five datasets including IC13, SVT, IIIT5K, IC15 and SVT-P when trained based on the two synthetic datasets.

irregular text datasets

 

 

 

5. Conclusion

extreme irregular text, we have presented the MDCDP module which utilizes positional feature to query both visual and semantic features within the attention-based encoder-decoder framework.

both visual and semantic domains.

MDCDP module

eight datasets that successfully validate our proposal.

The result on augmented datasets shows larger accuracy margin is observed as the severity of deformation increases.

ablation studies

state-of-the-art accuracy when compared with existing methods on six standard benchmarks.

In addition, the visualization experiments also basically verify that superior attention localization are obtained in both visual and semantic domains.

반응형
반응형

YOLO9000:Better, Faster, Stronger

Abstract

개선된 모델 YOLOv2는 PASCAL VOC and COCO 같은 standard detection tasks 에 대한 state-of-the-art 이다.

새롭고 다양한 규모의 학습 방법을 사용하면 동일한 Yolov2 모델을 다양한 sizes로 실행할 수 있으므로 속도와 정확도 사이에서 쉽게 trade-off 할 수 있따.

VOC 2007에서 67 FPS이고 76.8 mAP, 40 FPS에서 78.6 mAP를 획득하는 ResNet및 SSD를 사용하는 Faster RCNN과 함께 state-of-the-art methods 을 능가하는 동시에 훨씬 더 빠르다.

jointly train on object detection and classification ⇒ YOLO9000 을 COCO detection dataset과 ImageNet Classification dataset을 이용해 동시에 학습시킨다. 000개 이상의 서로 다른 개체 범주에 대한 탐지를 예측가능하며 여전히 실시간으로 실행된다.

1. Introduction

General purpose object detection 빠르고 정확하며 다양한 물체를 인식할 수 있어야 한다. fast and accurate을 증가 하였지만 여전히 a small set of objects제한이 있다.

현재의 object detection datasest는 classification 및 tagging 지정과 같은 other tasks을 위한 dataset에 비해 제한적이다.

hierarchical view of object classification

joint training algorithm, classification images to increase its vocabulary and robustness 활용하여 objects를 정확하게 지역한하는 방법을 학습

YOLO9000 a real-time object detector 9000 종에 대해서 할 수 있따.

  1. YOLOv2, a state-of-the-art, real-time detector
  2. our dataset combination method and joint training algorithm to train a model on more than 9000 classes from ImageNet as well as detection data from COCO

http://pjreddie.com/yolo9000/.

2. Better

Fast R-CNN과 비교한 YOLO의 Error analysis 은 Yolo 가 상단한 localization error 를 발생시킨다.

YOLO has relatively low recall compared to region proposal-based methods

따라서 우리는 분류 정확도를 유지하면서 recall과 localization를 개선하는 데 주로 중점을 둡니다.

larger, deeper networks 경향이 있다. 더 좋은 성능은 더 큰 network를 훈련하거나 여러 model을 함께 앙상블 하는데 달려있다. 그러나 Yolov2를 사용하면 여전히 빠른 더 정확한 detector가 필요한다. network를 확장하는 대신 network를 단순화한 다음 representation을 더 쉽게 배울 수 있도록 한다.

다양한 아이디어를 사용

Batch Normalization

다른 형태의 regularization에 대한 필요성을 제거하면서 수렴을 크게 향상시킨다. 모든 convolution layer에 batch normalization을 추가하면 mAP를 2% 향상시켰다. 모델을 정규화 하는데도 도움이 되고 overfitting 없이 dropout 를 제거할 수 있따.

High Resolution Classifier

YOLO classifier network를 224x224에 학습한 다음 448x448 의 해상도에서 detection network를 학습하였다. object detection을 학습하면서 동시에 새로운 input resolution 에 적용해야 하는 것을 의미한다.

YOLOv2 classifier network ImageNet full 448 × 448 resolution 10 epoch → 이는 network 가 더 높은 resolution input에서 더 잘 작동하도록 filter를 조정할 시간을 준다. 그다음에 fine tune the resulting network on detection. mAP를 4% 향상시켰다.

Convolutional With Anchor Boxes

Yolo는 convolutional feature extractor 위에 fully -connected layer를 통해 직접 bounding box 좌료를 예측, 우리는 Yolo에서 fully-connected layer를 제거하고 bounding box 예측을 위해 anchor box를 사용한다. pooling layer를 제거하고 network의 convolution layer의 출력을 더 높은 해상도로 만든다. 448 x 448 대신 416개의 input image에서 작동하도록 network에서 축소한다.

a single center cell 을 갖는 feature map을 위해 홀 수 개의 위치를 갖는다 . 이는 큰 물체는 이미지의 중앙을 차지하는 경향이 있으므로 모두 근처에 있는 4개 위치 대신 이런한 물체를 예측하기 위해 중앙에 단일 위치를 갖는 것이 좋다. YOLO의 convolutional layer는 32배 만큼 이미지를 downsampling하므로 416 input image를 사용하여 13x13 출력 feature map을 얻는다. ⇒ 조금 더 작은 물체

 

anchor box로 이동할 때 class prediction mechanism 을 spatial location 에서 분리하고 대신 모든 anchor box에 대한 class와 객체성을 예측한다. Yolo에 이어 objectness prediction 은 여전히 ground truth의 IOU를 예측하고 제안된 box 및 class predictions은 object가 있는 경우 해당 class의 conditional probablility 을 예측한다.

Anchor box를 사용하면 정확도가 약감 감소한다. Yolo는 이미지당 98(772)개의 box만 예측하지만 anchor box는 천 개 이상을 예측한다. anchor boxes가 없으면 중간 모델은 81%의 recall과 함께 69.5mAP를 얻는다. mAP가 감소하더라도 recall의 증가는 우리 모델이 개선할 여지가 더 많다는 것을 의미한다. ⇒ recall이 좋아졌다는 의미는 물체를 더 잘 찾아난다는 것이기 때문에 성능만 조금 더 개선하면 improve 한다는 여지가 있다.

Dimension Clusters

box dimension는 수동적으로 결정하였따. ⇒ k-Means Clustering 방법으로 개선

Euclidean distance와 함께 standard k-means clustering을 사용하는 경우 큰 box는 작은 box보다 더 많은 오류를 생성한다. 그러나 원하는 것은 box의 크기와 무관한 좋은 IOU scores로 이어지는 사전 순위이다. distance metric

d(box,centroid)=1−IOU(box,centroid)

k= 5가 모델의 recall vs. model complexity 에 대해 좋은 tradeoff을 제공한다는 것을 발견하였다.

 

Cluster SSE (Sum of Square Error) 5

anchor box를 9개에서 5개로 줄임,

9개의 Cluster IOU를 사용하면 훨씬 더 높은 IOU를 볼 수 있다. 이것은 bounding box 를 생성하기 위해 k-평균을 사용하면 더 나은 representation으로 model을 시작하고 task을 더 쉽게 학습할 수 있다.

 

 

 

 

Cluster SSE (Sum of Square Error) 5

anchor box를 9개에서 5개로 줄임,

9개의 Cluster IOU를 사용하면 훨씬 더 높은 IOU를 볼 수 있다. 이것은 bounding box 를 생성하기 위해 k-평균을 사용하면 더 나은 representation으로 model을 시작하고 task을 더 쉽게 학습할 수 있다.

Direct location prediction

anchor box의 문제점 2: model instability 특히 초기 iteration 동안

원인은 : box의 (x,y)위치를 예측하는데서 발생 ,

region proposal networks에서 network는 tx및 ty값을 예측하고 (x,y) center coordinates는 다음과 같이 계산한다.

x=(tx∗wa)−xa

y=(ty∗ha)−ya

이 공식은 제한이 없으므로 bounding box를 예측한 위치에 관계 없이 모든 anchor box가 image의 어느 지점에서나 깥날 수 있다. random 초기화 를 사용하면 model이 합리적인 offset을 예측하기 위해 안정화되는데 오랜 시간이 걸린다.

각 cell에 5개의 bounding box 예측

5 coordinates : tx, ty, tw, th, and to

cell의 image의 left corner (cx,cy)만큼 offset되고 bounding box 이전의 width와 height가 pw, ph 인 경우 예측은 다음과 같다.

pw,ph: anchor box의 너비 및 높이

bounding box center location을 directly predicting 하는 것과 함께 Dimension clustering을 사용하면 anchor box가 있는 버전보다 5%의 성능 향상된다.

Fine-Grained Features

passthrough layer

26 × 26 × 512 feature map → 13 × 13 × 2048 feature map → 큰물체 작은 물체를 더 잘 뽑아내게

13 × 13 × 2048 feature map 큰 물체를 탐지 못할 수 있다.

1% performance increase

YOLO v2의 13x13 feature map은 큰 물체를 탐지하는데 충분할 수 있으나 작은 물체를 잘 탐지하지 못 할 수 있다. 이를 해결하기 위해 13x13 feature map을 얻기 전의 앞 쪽의 layer에서 26x26 해상도의 feature map을 passthrough layer를 통해 얻는다.

사진 4. fine-grained features

위의 사진 4와 같이 26x26x512 -> 13x13x2048로 분해한 후 기존의 output인 13x13 feature map과 concatenate를 수행한다. 이러한 방법으로 1%의 성능을 향상시켰다.

Multi-scale Training

multi-scale training {320, 352, ..., 608}. 32배 사이즈로 다양하게 학습 ⇒ 같은 network인데 다양한 resolution을 예측할 수 있다.

 

Further Experiments.

3. Faster

Darknet-19을 backbone network로 사용한다.

VGG-16 대신 Googlenet architecture을 사용 Googlenet architecture 속도가 더 빠르지만 정확도가 조금 낮다.

Darknet-19

VGG와 비슷(3 × 3 filters 사용)

Network in Network (NIN) 작업에 이어 global average pooling 을 사용하여 predictions를 수행하고 1 × 1 filters 를 사용하여 3 × 3 convolutions 사이의 특징 표현을 압축한다. 훈련을 안정화하고 수렴 속도를 높이며 모델을 정규화하기 위해 batch normalization를 사용한다.

19 convolutional layers and 5 maxpooling layers.

Training for classification

ImageNet 1000 class classification dataset 160 epochs

g stochastic gradient descent, learning rate 시작은 0.1,

polynomial rate decay with a power of 4

weight decay of 0.0005

momentum 0.9

standard data augmentation : random crops, rotations, and hue, saturation, and exposure shifts.

224x224 해상도로 학습한 후 448로

fine tuning : 위의 parameter 사용 , 10 epochs , learning rate of 10−3

 

Training for detection

last convolutional layer을 제거하고 3개의 3 × 3 convolutional layers with 1024 filters each followed by a final 1 × 1 convolutional layer with the number of outputs we need for detection.

4. Stronger

jointly training on classification and detection data.

Hierarchical classification : 계층적인 분류를 사용한다.

WordNet는 data구조이고 tree는 아니다.

softmax

Hierarchical classification

조건부 확률고 계산

absolute probability for 특정 node

P r(physical object) = 1.

Dataset combination with WordTree

Joint classification and detection

Yolo9000

output size를 제한하기 위해 5개 대신 3개만 사용

detection backpropagate loss as normal

classification loss only classification loss is backpropagated at or above the corresponding level of the label.

5. Conclusion

real-time detection system YOLOv2 and YOLO9000

Yolov2 state-of-the-art faster , accuracy

YOLO9000 a real-time framework jointly optimizing detection and classification WordTree

hierarchical classification

multi-scale training

 

 

논문 출처 : YOLO9000: Better, Faster, Stronger

파파고, 구글  번역을 많이 사용하였다. 

반응형
반응형

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

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

반응형
반응형

Ashish Vaswani ∗  Google Brain
Noam Shazeer ∗  Google Brain
Niki Parmar ∗  Google Research
Jakob Uszkoreit ∗  Google Research
Llion Jones ∗  Google Research
Aidan N. Gomez ∗ † University of Toronto
Łukasz Kaiser ∗ Google Brain
Illia Polosukhin ∗ ‡

 

sequence-aligned RNNs or convolution없이

self-attention

additive attention [2]와 dot-product (multiplicative) attention

"encoder-decoder attention" layers

encoder contains self-attention layers

self-attention layers in the decoder

 

Abstract

dominant sequence transduction models은 encoder와 decoder를 포함하는 복잡한 recurrent or convolutional neural networks을 기반으로 한다. (RNN , CNN) 최고 성능의 모델은 또한 attention mechanism을 통해 encoder와 decoder를 연결한다. 우리는 RNN와 CNN없어도 되는 attention mechanisms만을 기반으로 하는 새로운 단순한 network architecture를 제안한다. two machine translation tasks 에 대한 실험에 따르면 이러한 모델은 품질이 우수하면서도 병렬화가 훨씬 용이하고 학습시간이 적게 소요된다. 우리의 모델은 WMT 2014 English-to-German translation task에서 28.4 BLEU를 달성하여 ensembles을 포함한 기존 최고의 결과보다 2 BLEU 이상 향상되었다. WMT 2014 English-to-French translation task에서 , 우리 모델은 8개의 GPU에서 3.5일 동안 훈련한 후 41.8의 new single-model state-of-the-art BLEU score 점수를 달성하며 , 이는 논문에서 최고의 모델 training costs 의 작은 부분이다. 우리는  Transformer가 크고 제한된 학습 데이터를 사용하여 English constituency parsing에 성공적으로 적용함으로써 다른 작업에 잘 일반화됨을 보여준다.

 

1 Introduction

 

Recurrent neural networks, 특히 long short-term memory (LSTM)[13] and gated recurrent [7](GRU) neural networks language modeling 및 machine translation [35, 2, 5]과 같은  sequence modeling및 transduction problems에서 state of the art접근방식으로 확고히 확립되었다. 그 이후로 recurrent language models and encoder-decoder architectures [38, 24, 15] 의 경계를 확장하려는 수많은 노력이 계속되고 있다. 

Recurrent models은 전형적으로 입력과 출력 sequence의 위치를 따라 factor를 계산한다. positions을  computation time에 정렬하면 , previous hidden state ht−1과 position t에 대한 입력의 함수로서 sequence of hidden states ht,를 생성한다. 이러한 sequential nature은 본질적으로 training examples내 parallelization 를 방지하는데, memory constraints 이 examples 긴 batching 를 제한하기 때문에, sequence lengths가 길어질 수록 매우 중요하다. 최근 연구는 factorization tricks [21] and conditional computation [32]을 통해 computational efficiency을 개선했으며 후자의 경우 모델 성능도 개선했다. 그러나 sequential computation의 근본적인 제약은 남아 있다.

Attention mechanisms은 다양한 작업에서 compelling sequence modeling와 transduction models의 적인 부분이 되었으며, input or output sequences [ 2 , 19 ] 에서의 거리에 관계 없이 의존성의 모델링을 가능하게 했다. 그러나 소수의 경우를 제외하고 [27 ] 그러한 attention mechanisms은 recurrent network와 함께 사용된다. 

본 연구에서 우리는 model architecture인 Transformer를 제안한다. Transformer recurrence 를 피하고 대신 input and output사이의 global dependencies을 끌어내기 위한 attention mechanism에 전적으로 의존한다. Transformer 는 8개의 P100 GPU에서 12시간만 학습해도 훨씬 더 많은 병렬화가 가능하고  translation quality 에서 새로운 state of the art에 도달했다. 

 

2 Background

sequential computation을 줄이는 목표는 또한 Extended Neural GPU [ 16 ], ByteNet [ 18 ] and ConvS2S [ 9 ]의 기초를 형성하며 , 이 모두는 convolutional neural networks 을 basic building block 요소로 사용하여 모든 입력 및 출력 위치에 대해 hidden representations을 병렬로 계산한다. 이러한 모델에서 , two arbitrary input또는 output positions 의 신호를 연관시키는데 필요한 작업 수는 ConvS2S의 경우 선형으로 , ByteNet의 경우 logarithmically 간 거리에 따라 증가한다. 이는 distant positions [ 12 ]사이의 의존성을 학습하는 것을 더욱 어렵게 만든다. Transformer에서 이것은 averaging attention-weighted positions로 인해, 유효 해상도가 감소하지만,  section 3.2에서 설명된 대로 Multi-Head Attention으로 대응한다. 

Self-attention는 sequence의 representation 을 계산하기 위해 single sequence의 다른 위치와 관련된 intra-attention attention mechanism이다. Self-attention은 reading comprehension, abstractive summarization, textual entailment and learning task-independent sentence representations [4, 27, 28, 22]를 포함한 다양한 과제에 성공적으로 사용되어 왔다. 

reading comprehension: 독해 

abstractive summarization: 생성 요약

textual entailment:  두 개의 주어진 문장 

Task-Independent Sentence : 

End-to-end memory networks는 sequence-aligned recurrence 대신 recurrent attention mechanism기반으로 하며 simple-language question answering 및 language modeling tasks [34]에서 잘 수행되는 것으로 나타났다. 그러나 우리가 아는 한, Transformer 는 sequence-aligned RNNs or convolution없이 input and output의 representations 을 계산하기 위해 self-attention에 의존하는 첫번째 모델이다. 다음 섹션에서는 Transformer에 대해 설명하고 , self-attention를 유도하며 [17, 18] and [9]와 같이 모델에 비해 이점에 대해 논의한다 .

 

3 Model Architecture

 

 

 

대부분의 competitive neural sequence transduction models은 encoder-decoder structure [ 5 , 2 , 35 ]를 가지고 있다. 여기서 encoder 는 symbol representations (x_1 ,...,x_n ) 를 연속 representations sequence  z = (z_1 ,...,z_n )에 매핑한다. 그런 다음 z 가 주어지면 decoder 는 한번에 하나의 요소씩 symbols 의 output sequence (y_1 ,...,y_m )를 생성한다. 각 단계에서 모델은 auto-regressive[10]으로 , 이전에 generated symbols 를 다음을 생성할 때 additional input으로 사용한다. Transformer 는 각각 Figure 1의 왼쪽과 오른쪽 절반에 표시된 바와 같이 encoder and decoder 모두에 대해 stacked self-attention and point-wise fully connected layers를 사용하는 전체적인 architecture 를 따른다. 

3.1 Encoder and Decoder Stacks

Encoder: encoder 는 N = 6 identical layers stack 으로 구성된다. 각 층에는 두 개의 sub-layer이 있다. 

첫번째는 multi-head self-attention mechanism 이고,

두번째는 simple하고 position-wise fully connected feed-forward network이다. 

우리는 two sub-layers 각각 주위에 residual connection [ 11 ] 을 사용하고 , 이어서 layer normalization [ 1 ]를 사용한다. 

즉 각 sub-layer의 출력은 LayerNorm(x + Sublayer(x))이며, 여기서 Sublayer(x)은 sub-layer 자체에 의해 구현된 함수이다. 

이러한 residual connections은 용이하게 하기 위해 embedding layers뿐만 아니라 모델의 모든 하위 레이어는 d model = 512의 output을 생성한다. 

Decoder : decoder 는 또한 N = 6 identical layers의 stack으로 구성되어 있다. 각 encoder layer 의, two sub-layers에도 decoder 는 third sub-layer을 삽입하여, encoder stack의 output 에 대해 multi-head attention 를 수행한다. encoder와 유사하게, 우리는 각 sub-layers 주위에 을 사용하고 , 이어서 layer normalization을 사용한다. 또한 decoder stack 의 self-attention sub-layer을 수정하여 positions 가 subsequent positions로 추가하는 것을 방지한다. 이러한 masking은, output embeddings이 한 position만큼 offset 된다는 사실과 결합되어 position i 에 대한 predictions 이 i보다 작은 positions 에서 알려진 출력에만 의존할 수 있도록 한다. 

3.2 Attention

attention functions는 query, keys, values, 및 output are all vectors output에 query와 key-value 쌍 집합을 mapping 하는 것으로 설명할 수 있다. output 은 각 value에 할당된 weighted 가 해당 keys와 query의 compatibility function에 의해 계산되는 값의 weighted sum으로 개선된다. 

 

3.2.1 Scaled Dot-Product Attention

우리는 우리의  particular attention을  "Scaled Dot-Product Attention"
(Figure 2)라고 부른다. input 은 dimension d_k의 queries and keys,  dimension d_v의 values 으로 구성된다. 우리는 query 의 dot products읍 all keys로 계산하고 , 각각을 √dk로 나눈 다음, softmax function를 적용하여 값에 대한 가중치를 구한다. 

가장 일반적으로 사용되는 두가지  attention functions은  additive attention [2]와 dot-product (multiplicative) attention이다. Dot-product attention은 1/√dk의 scaling factor를 제외하고  우리의 algorithm과 동일하다. Additive attention은  single hidden layer가 있는 feed-forward network를 사용하여 compatibility function를 계산한다. 이 두가지는 이론적으로 복잡성은, 유사하지만, highly optimized matrix multiplication code를 사용하여 구현할 수 있기 때문에 실제로 dot-product attention 는 훨씬 빠르고 공간 효율적이다. 

d_k의  small values의 경우 두 mechanisms 이 유사하게 수행되지만,  additive attention는 d_k[3]의 larger values 에 대한 scaling 없이 dot product attention보다 우수하다. => 작을 때 이 두 비슷하는데 큰 value일 경우 additive attention유리하다. 이러한 효과에 대응하기 위해 우리는 dot products by 1/√dk으로 scale 한다. 

dot products 커지는 이유를 설명하기 위해 q와 k의 components 이 평균 0과 분산이 1인 independent random variables라고 가정한다. 따라서 dot product은 q * k = \sum_{d=1}^{d_k} q_i k_i 평균 0과 분산 dk를 갖는다.

3.2.2 Multi-Head Attention

d_model-dimensional keys, values 및 queries를 사용하여 single attention function을 수행하는 대신, 우리는 학습된  d_k, d_k 및  d_v dimensions 에 각각 다른 linearly project the queries을 사용하여 queries, keys 및 values h times  linear projections것이 유익하다는 것을 발견하였다. 이러한 queries, keys 및 values의 각 projected 버전에서 attention function을 병렬로 수행하여 d_v-dimensional output values을 산출한다. 이것들은 연결되고 다시 투사되어 Figure 2에서와 같이 최종 값이 산출된다. Multi-head attention를 통해 모델은 서로 다른 위치의 서로 다른 표현 sub-spaces의 정보에 공동으로 attend 할 수 있다.  single attention head우로 averaging산출은 이것을 엊게한다. 

MultiHead(Q, K, V ) = Concat(head_1, ..., head_h)W^O

where head_i = Attention(QW^Q_i, KW^K_i, V W^V_i)

여기서 projections 은 parameter matrices이다. 

이 작업에서는 h = 8 parallel attention layers 또는 heads를 사용한다. 각각의 경우 d_k = d_v = d_model/h = 64를 사용한다. 각 head의 reduced dimension로 인해 총 계산 비용ㅇㄴ 전체 dimensionality를 갖는 single-head attention 비용과 유사하다. 

3.2.3 Applications of Attention in our Model

Transformer 는 3가지 다른 방식으로 multi-head attention을 사용한다. 

  • "encoder-decoder attention" layers에서 , queries 는 이전  decoder layer에서 나오고 , 메모리 keys 와 values값은 encode의 출력에서 나온다. 이를 통해 decode의 모든 positions가 input sequence의 모든 위치에 배치될 수 있다. 이는 [38, 2, 9]와 같은 sequence-to-sequence models에서 일반적인 encoder-decoder attention mechanisms을 모당한다. 
  • encoderd에는 self-attention layers가 있다. self-attention layer에서 모든 keys, values및 queries 는 동일한 place에서 발생하며, 이 경우 encoder에 있는 이전 layer의 output이다. encoder 의 각 위치는 encoder의 previos layers에 있는 모든 position을 관리할 수 있다. 
  • 마찬가지로, decoder의 self-attention layers를 통해 decoder의 각 position 는 해당 position 까지 decoder의 모든 position 에 집중될 수 있다. 우리는 auto-regressive property을 보존하기 위해 decoder에서 왼쪽으로 향하는 흐름을 막아야 한다. 우리는  illegal connections에 해당하는 softmax input의 모든 values을 masking out((setting to −∞) 하여 scaled dot-product attention 에서 이를 구현한다. Figure 2참조

3.3 Position-wise Feed-Forward Networks

attention sub-layers 외에도 encoder 및 decoder 의 각 layers에는 완전히 연결된  feed-forward network 포함되고 있으며 이는 각 위치에 개별적으로 동일하게 적용된다. 이것은 중간에 ReLU activation 가 있는 두가지 linear transformatins으로 구성된다. 

linear transformations은 다른 position에서 동ㅇ일하지만 layers마다 다른 parameter를 사용한다. 이것을 설명하는 또 다른 방법은 kernel size 가 1인 두개의 convolutions 을 사용하는 것이다. 입력과 출력의 차원은 d_model = 512이고, inner-layer has dimensionality은 d_ff = 2048이다. 

3.4 Embeddings and Softmax

다른 sequence transduction models과 유사하게, 우리는 학습된 embeddings 을 사용하여 input tokens과 output token을 차원 d_modeldml vectors로 변환한다. 또한 일반적으로 학습된 linear transformation과 softmax function를 사용하여 decoder output을 predicted next-token probabilities로 변환한다. 우리의 모델에서 , 우리는 [30]과 유사한 두 embedding layers와  pre-softmax linear transformation사이에서 동일한 weight matrix를 공유한다.  embedding layers에서 , 우리는 그러한 weight에 √d_mode를 곱한다. 

3.5 Positional Encoding

우리의 모델은 recurrence and no convolution이 없기 때문에, 모델이 sequence의 순서를 사용하기 위해서는 sequence에서 token의 상대적인 위치 또는 절대적인 위치에 대한 정보를 주입해야 한다. 이를 위해, 우리는 encoder and decoder stacks의 하단에 있는 input embedding에 "positional encodings"을 추가한다. positional encodings은 embedding과 동일한 dimension d_model을 가지므로 둘을 합칠 수 있다. positional encodings, learned and fixed [9]의 많은 선택이 있다. 

본 연구에서는 서로 다른 frequencies의 sine및 cosine functions를 사용한다. 

pos 는 position 

i는 dimension

즉 , positional encoding 의 각 dimension은 sinusoid에 해당한다. 2π to 10000 · 2π까지 geometric progression으로 진행된다. fixed offset k에 대하 P Epos+k는 P Epos의  linear function으로 표현될 수 있기 때문에 모델이 상대적 위치에 따라 attend 하는 것을 배울 수 있다고 가정했기 때무에 이 함수를 선택했다. 

우리는 또한 학습된 positional embeddings[9] 을 대신, 사용하여 실험했고 두 버전이 거의 동일한 결과를 산출한다는 것을 발견했다. (see Table 3 row (E))

우리는 모델이 학습 중에 마주치는 것보다 더 longer sequence 길이로 추론할 수 있기 때문에 sinusoidal version을 선택했다. 

 

 

 

4 Why Self-Attention

이 Section에서, 우리는 self-attention layers 의 다양한 aspects 을 typical sequence transduction encoder or decoder와 같은 xi, zi ∈ R^d에 하나의 variable-length sequence of symbol representations 를 mapping하는데 일반적으로 사용되는 recurrent and convolutional layers와 비교한다. self attention 의 사용에 동기를 부여하면서 세가지 필요성을 생각한다. 

  1. 계층당  layer 총 computational complexity 이다. 
  2. 또 다른 하나는 필요한 최소 sequential operations 수로 측정할 때 parallelized할 수 있는 계산의 양이다.
  3. network에서 long-range dependencies사이의 경로 길이이다. long-range dependencies학습하는 것은 많은 sequece transduction tasks에서 핵십 과제이다. 이러한 종속성을 학습하는 능력에 영향을 미치는 한 가지 주요 요인은 network에서 forward and backward signals가 통과해야 하는 경로의 길이이다. input and output sequences의 positions 조합 사이의 이러한 경로가 짧을수록, long range dependencies [12] 학습하기가 더 쉬워진다.따라서 우리는 또한 다른 layer types으로 구성된 network에서 두 input and output positions 사이의 maximum path length를 비교한다. 

Table 1에서 언급한 바와 같이, self-attention layer 은 all positions 를 sequentially executed operations의 constant number로 연결하는 반면, recurrent layer은 requires O(n) sequential operations을 필요로 한다. computational complexity에서 , self-attention layers은 sequece length n이 representation dimensionality d보다 작을 때 recurrent layers 보다 빠르다. (n < d) 이는  word-piece [38]및 byte pair [31] representations과 같은 machine translations에서 state-of-the-art models에 의해 문장 표현에 가장 많이 해당된다.  very long sequences를 포함하는 tasks 에 대한 computational performance을 개선하기 위해, self-attention는 각 output position를 중심으로 하는 input sequence r size의 neighborhood 만 고려하는것으로 제한될 수 있다. 그러면 maximum path length to O(n/r)으로 증가한다. 우리는 향수 연구에서 접근 방식을 더 조사할 계획이다. 

kernel width k < n인 single convolutional layer는 모든 input and output positions 쌍을 연결하지 않는다. 그렇게 하려면 contiguous kernels의 경우 O(n/k) convolutional layers의 stack 또는 dilated convolutions [18]의 경우 O(logk(n))가 필요하며 , network의  two positions사이의 가장  경로 의 길이를 증가시킨다. Convolutional layers는 일반적으로 recurrent layers보다 k배 더 비싸다. 그러나 Separable convolutions [6] 은 complexity 을 O(k · n · d + n · d^2 )로 상당히 감소시킨다. k = n인 경우에도 a separable convolution 의 complexity은 model에서 취하는 접근 방식은 self-attention layer과 point-wise feed forward layer의 조합과 같다. 

부수적인 이익으로, self-attention는 더 해석 가능한 모델을 산출할 수 있다. 우리는 model의 attention distributions 를 검사하고 appedix에서 예를 제시하고 논의한다. individual attention heads는 분명히 다른 작업을 수행하는 방법을 배울 뿐만 아리라 , 많은 주의력이 sentences의 syntactic 및 semantic structure 와 관련된 행동을 보이는 것으로 보인다. 

 

5 Training

이 Section에서는 model을 위한 training regime에 대해 설명한다.

5.1 Training Data and Batching

우리는 4.5 million sentence pairs으로 구성된 standardW MT 2014 English-German dataset 에 대해 학습했다. Sentences 은 약 37000 tokens의 shared source target vocabulary을 가진 byte-pair encoding [3]을 사용하여 인코딩 되었다. English-French의 경우 36M sentences과 tokens into a 32000 word-piece vocabulary [38]로 분할 한 larger WMT 2014 English-French dataset를 사용했다. Sentence pairs 은 대략적인 sequence length로 배치되었다. 각 training batch에는 약 25000 source tokens과 25000 target tokens을 포함하는 sentence pairs가 포함되어 있었다. 

5.2 Hardware and Schedule

우리는 8 NVIDIA P100 GPUs가 있는 하나의 machine에서 모델을 학습하였다. 본 문서 전체에 설명된 hyperparameters 를 사용하는 기본 모델의 경우 각 학습 단계는 약 0.4초가 소요되었다. base model을 총 100,000 steps 또는 12기간 동안 학습했다. big models(described on the bottom line of table 3)의 경우 step time은 1.0 초이다. big models들은 300,000 steps(3.5일) 동안 학습을 받았다. 

5.3 Optimizer

β1 = 0.9, β2 = 0.98 및 ε(엡실론)=10^-9와 함께 Adam 옵티마이저[20]를 사용했다. 학습 과정에 따라 learning rage을 다음과 같은 공식에 따라 변화시켰다. 

공식 (3)

이는 첫번째 warmup_steps 학습 단계에 대해 learning rate를 선형적으로 증가시키고 그 이후 단계의 inverse square root에 비례하여 감소시키는 것에 해당한다. 우리는 warmup_steps = 4000을 사용했다. 

 

5.4 Regularization

우리는 학습중에 세가지 유형의  regularizatoin을 사용한다. 

Residual Dropout sub-layer에 추가되고 , 정규화하기 전에 각 sub-layer의 출력에 dropout [33]을 적용한다. 또한 encoder and decoder stacks의 embedding 및 positional encoding 합계에 dropout을 적용한다. 기본 모델의 경우 P_drop = 0.1의 비율을 사용한다.

Label Smoothing 학습중에 , 값 εls = 0.1 [36]의 label smoothing 을 사용했다 . 이는 모델이 더 확신하지 못하는 것을 학습함에 따라 복잡성을 감소시키지만 정확도와 BLEU score를 향상시킨다. 

 

6 Results

6.1 Machine Translation

WMT 2014 English-to-German translation task에서 big transformer model (Transformer (big) in Table 2) 은 이전에 보고된 models(ensembles 포함)보다  2.0 BLEU이상 우수하여 28.4 라는 new state-of-the-art BLEU score 를 달성했다. 이 모델의 구성은 Table 3의 맨 아래 줄에 나열되어 있다. 학습은 8개의 P100 GPUs에서 3.5일이 걸렸다. 심지어 우리의 기본 모델도 competitive models보다 훨씬 적은 비용으로 이전에 published models과 ensembles을 능가한다. 

WMT 2014 English-to-French translation task에서 big models은 BLEU score of 41.0을 달성하여 이전  state-of-the-art model 의 training cost 의 1/4미만으로 이전에 published single models을 능가한다. English-to-French학습을 받은 Transformer (big) model은 0.3 대신 dropout rate P_drop = 0.1을 사용했다. 

base models의 경우  10분 간격으로 작성된 마지막 5개의 checkpoints를 평균화하여 얻은 single model을 사용했다. beam size가 4이고 penalty α = 0.6 [38]인 beam search를 사용했다. 이 hyperparameters 는 development set에 대한 실험 후에 선택되었다. 우리는 추론 중 maximum output 를 input length + 50 으로 설정하지만, 가능하면 조기종료한다 [38]. 

Table 2는 결과를 요약하고 translation quality및 training costs을 논문의 다른 모델 아키텍처와 비교한다. 우리는 학습 시간, 사용된 GPU 수 및 각 GPU 의 sustained  single-precision floating-point capacity  추정치를 곱하여 모델을 훈련하는 데 사용되는 floating point operations를 추정한다. 

GPU : We used values of 2.8, 3.7, 6.0 and 9.5 TFLOPS for K80, K40, M40 and P100, respectively. 

6.2 Model Variations

Transformer의 다양한 구성 요소의 중요성을 평가하기 위해 development set, newstest2013에서 English-to-German translation 의 번역의 성능 변화를 측정하는 다양한 방식으로 기본 모델을 변경했다. 이전 section에서 설명한 대로 beam search 을 사용했지만 checkpoint averaging 은 사용하지 않았다. 우리는 이러한 결과를 Table 3에서 제시한다. 

Table 3 rows (A)에서 , 우리는 3.2.2 section에서 설명한 것과 같이 계산의 양을 일정하게 유지하면서 attention heads 의 수와 attention key 및 value dimensions를 변화시킨다. single head attention 이 최적의 설정보다 0.9 BLEU나 나쁘지만 head가 너무 많으면 품질도 떨어진다. Table 3 rows (B)에서는 attention key dk 를 줄이면 model quality가 저하된다는 것을 관찰했다. 이는 호환성 판별이 쉽지 않고 dot product 제품보다 정교한 호환성 기능이 유리할 수 있음을 시사한다. 또한 rows (C) and (D) 에서 예상대로 큰 모델이 더 낫고 dropout이 과적합을 방지하는 데 매우 도움이 된다는 것을 관찰했다. row (E) 에서 우리는 sinusoidal positional encoding을 학습된 positional embeddings [9]으로 대체하고 기본 모델과 거의 동일한 결과를 관찰한다. 

6.3 English Constituency Parsing

Transformer 가 다른 작업으로 일반화할 수 있는지 평가하기 위해 English constituency parsing 분석데 애한 실험을 수행했다. 이 작업은 출력이 강력한 구조적 제약을 받으며 입력보다 상당히 길다는 특정한 과제를 제시한다. 또한 RNN sequence-to-sequence models은 small-data regimes[37]에서 state-of-the-art results 를 얻을 수 없었다.

우리는 약  40K training sentences인 Penn Treebank [25]의 the Wall Street Journal (WSJ) portion에서 d_model = 1024 인 4-layer transformer 를 학습시켰다. 또한 약 17M sentences [37]으로 더 high-confidence and BerkleyParser corpora

를 사용하여 준 semi-supervised setting에서 학습했다. WSJ 전용 설정에는 6K tokens의 vocabulary를 , semi-supervised setting에는 32K tokens의 어휘를 사용했다. 

Section 22 development set에서  attention and residual (section 5.4), learning rates and beam size 를 선택하기 이ㅜ해 소수의 실험만 수행했으며, 다른 모든 parameters는 English-to-German base translation model에서 변경되지 않았다. inference하는 동안 maximum outputput length 를 input length + 300으로 늘렸다. 우리는 WSJ 전용및 semi-supervised setting 모두에 대해 beam size of 21 and α = 0.3를 사용했다. 

Table 4의 결과는 task-specific tuning이 부족함에도 불구하고 우리의 모델이 놀라울 정도로 잘 수행되어 Recurrent Neural Network Grammar [8]을 제외하고 이전에 보고된 모든 모델보다 더 나은 결과를 산출한다는 것을 보여준다. 

RNN sequence-to-sequence models [37]과 대조적으로 , Transformer 는 40K sentences으로 구성된 WSJ training set 에 대해서만 학습하는 경우에도 BerkeleyParser [29]를 능가한다. 

7 Conclusion

본 연구에서는 encoder-decoder architectures에서 가장 일반적으로 사용되는 recurrent layers 를 multi-headed self-attention으로 대체하여 entirely on attention 기반으로 하는 첫 번째 sequence transduction model인 Transformer를 제시하였다. 

 translation tasks의 경우, Transformer 는 recurrent or convolutional layers를 기반으로 한 architectures 보다 훨씬 더 빠르게 훈련할 수 있다. WMT 2014 English-to-German and WMT 2014 English-to-French translation tasks에서 우리는 새로운 state of the art을 달성했다. 이전 작업에서 우리는 최고의 model은 이전에 보고된 모든 ensembles를 능가한다. 

우리는 attention-based models의 미래가 기대되면 다른 작업에 적용할 계획이다. 우리는 Transformer를 text가 아닌 inputs and ouptuts 양식과 관련된 문제로 확장하고 이미지, 오디오 와 같은 큰 inputs and ouptuts을 효율적으로 처리하기 위해 제한된 local attention mechanisms을 조사할 계획이다. generation 를 덜 순차적으로 만드는 것은 우리의 또 다른 연구 목표이다. 

모델을 학습하고 평가하는 데 사용한 코드는 https://github.com/tensorflow/tensor2tensor에서 확인할 수 있다. 

 

 

 

Attention Is All You Need

 

Attention Is All You Need

The dominant sequence transduction models are based on complex recurrent or convolutional neural networks in an encoder-decoder configuration. The best performing models also connect the encoder and decoder through an attention mechanism. We propose a new

arxiv.org

번역할 경우 파파고의 예제를 많이 사용하였다. 

반응형
반응형

Abstract

기존 연구의 소개 및 특징

본 연구 제시

본 연구의 결과

본 연구 구체적 결과 및 우수성

 

Introduction => 1장 제목 자체 

모든 chapter에서 가장 중요한 chapter

반드시 5개이 문단이 온다.

  1. 연구 배경 및 필요성
  2. 기존 연구들의 소계 한계점 단점
  3. 기존 연구에 대한 상황설명 끝 부분에 단점을 언급
  4. 본 연구의 우수성 , 기대효과 및 장점 본 논문의 목적 , 방법 , 결과
  5. 논문의 구성 

 

 

 

 

 

 

Big Data Koo (SKKU BigLab) 에서 영어공부 논문으로 완성하자 를 참조하여 만든 내용이다.

 

반응형
반응형

Rnn은 사용하지 않는다.

학습이 빠르고 성능이 좋다.

 

왜 빨랐을 가 ?

RNN을 사용하지 않았다.

병렬화 : 일을 최대한 한방에 처리한다.

 

Rnn은 순서로 해서 하나하나 입력해서 한다. 

중간에 context vector이 있다.

context vector : 고정된 크기 

긴 문장은 잘 안된다.

 

RNN based encoder decoder with attention: 

동적으로 사용한다.

하지만 느리다. 

 

Transformer :

rnn 을 제거하였다. 

한번에 학습한다.

 

RNN은 단어의 위치와 순서 저보를 잘 할 수 있기 떄문이다.

 

Positional encoding

sign, cosin 을 이용하면장점이 있다.

-1 ~ 1까지의 값이고 

에러가 없이 상대적인 encoding이 가능하다.

 

self attention 

encoding에서 주어진 연산

query ,key , value는 행렬곱으로 한방에 할 수 있다.

상관관계를 곱할때 query * key 곱해서 attention score이라고 한다.

숫자로 나오고 단어 연관성이 높다 낮으면 연관성이 낮다.

 

순차적으로 해서 병렬 처리에 가장 큰 장점입니다.

 

multi- head attention

 

병렬로 동시에 수행하여 

 

encoder는 가중치를 공유하지 않고 

 

decoder 동이란 layer 

순차적으로 출력한다.

masked multi-head attention : 지금 까지 출력한 값들에만 대해서 masked 붙여진 것이다.

multi- head attention : 가장 큰 차이점은 현재 query 로 사용하고 최종 출력값을 key  value로 한다.

 

label smoothing : 1에 가깝지만 1이 아니고 0에 가깝지만 0이 아닌 

 

 

 

https://www.youtube.com/watch?v=mxGCEWOxfe8

 

반응형

+ Recent posts