우리는 high-speed regime(높은 속도 체제)에서 accuracy and efficiency 간의 trade-off를
optimize하는 image classification architecture를 design했다.
우리의 연구는 highly parallel processing hardware에서 경쟁력 있는
attention-based architecture에 대한 recent findings(최신의 발견)을 활용했다.
우리는 CNN에 대한 광범위한 연구에서의 principles들을 다시 검토하여
이를 Transformer에 적용하고,
특히 resolution이 감소하는 activation maps을 도입했다.
또한, Vision transformer에서 positional information을 통합하는 새로운 방식인
attention bias를 도입했다.
결과적으로,
우리는 fast inference image classification을 위한 hybrid neural network인 LeViT
를 제안한다.
우리는 다양한 HW platform에서 Efficiency 측정을 고려하여 광범위한 application scenarios를 반영하려고 했다.
우리의 광범위한 실험은 우리의 기술적 선택이 대부분의 architecture에서 적합함을 실증적으로 입증한다.
전반적으로, LeViT는 speed/accuracy tradeoff 측면에서 기존의 ConvNet과 Vision Transformers를 능가한다.
(예를 들어, 80% ImageNet Top-1 acc에서 LeViT는 CPU에서 EfficientNet보다 5배 빠름)
(We release the code at https://github.com/facebookresearch/LeViT)
이 논문에서는 ViT/DeiT model보다
small and medium-sized architectures 영역에서 더 나은 trade-offs를 제공하기 위해 design space를 탐구한다.
우리는 특히 performance-accuracy trade-off,
예를 들어 ImageNet-1K-val에 대한 Figure 1에 나타난
throughput(images/speed) performance를 optimizing하는 데에 관심이 있다.
많은 연구가 classifier and feature extractors의 memory footprint를 줄이는 것을 목표로 하는 반면,
inference speed도 동일하게 중요하며 high throughput은 better energy efficiency와도 연관된다.
이 연구에서 우리의 목표는
GPU와 같은 고도로 병렬적인 architecture, 일반적인 Intel CPU, mobile device에서 흔히 볼 수 있는 ARM HW에서 더 나은 inference speed를 가진
vision transformer-based family of models을 개발하는 것이다.
우리의 solution은 Transformer components 대신
convolution-like features(convolution과 유사한 특징)을 학습하는
convolution components를 re-introduce(다시 도입)한다.
특히, 우리는 Transformer의 uniform structure를
LeNet architecture와 유사하게 pooling이 있는 Pyramid로 대체한다.
따라서 우리는 이를 LeViT라고 부른다.
computational complexity에서 Transformer가 Convolution architectures보다 빠른 이유는 다음과 같은 설득력 있는 이유들이 있다.
대부분의 HW accelerators(GPUs, TPUs)는 large matrix multiplications을 수행하도록 최적화되어 있다.
Transformer에서는 attention과 MLP block이 주로 이러한 연산에 의존한다.
반면에, convolution은 complmex data access pattern을 요구하기 때문에
그 연산은 종종 IO에 의해 제한된다.
이러한 considerations은 speed/accuracy tradeoff를 탐구하는 데 중요하다.
(skip)
vision을 위한 neural network architecture에서
attention mechanism을 포함하려는 연구들이 있었다.
mechanism은 channel-wise로 사용되어,
convolution layer를 보완하는 cross-feature information을 capture하거나,
network의 다른 branch에서 path를 선택하거나,
혹은 이 두가지를 결합하는 데에 사용된다.
예를 들어,
the squeeze-and-excite network of Hu et al.은
layer의 feature들 간의 channel-wise relationship을 modeling하기 위한 attention module을 포함하고 있다.
또한, Li et al.[37]은 network branch 간의 attention mechanism을 사용하여
neuron의 receptive field를 적응적으로 조정한다.
최근에 Transformer의 등장은 다른 Module들의 이점을 누리는 hybrid architecture를 이끌어냈다.
Bello [45]는 positional attention component와 함께 approximated content attention을 제안했다.
Child et al.[23]은 network의 초기 layer가 지역적으로 연결된 pattern을 학습하는 것을 관찰했는데,
이는 convolution과 유사한 pattern이다.
이는 Transformer와 Convolution Network에서 영감을 받은 hybrid architecture가 유명한 design choice임을 시사한다.
몇몇 최근 연구들은 다양한task를 위해 hybrid architecture 방식을 탐구하고 있다.
image classification에서는, Pyramid Visoin Transformer(PVT)가 우리의 연구와 병행하여 발표되었는데,
이는 ResNet에서 영감을 받은 design으로 주로 object 및 instance segmentation task을 처리하기 위해 설계되었다.
또한 우리의 연구와 동시에,
Yuan et al.은 Tokens-to-Tokens ViT(T2T-ViT) model을 제안했다.
PVT와 유사하게, 이 Model의 설계는 각 layer 후에 output을 re-tokenization하여
주변 token들을 aggregating함으로써 점진적으로 token 수를 줄이는 데 의존한다.
이러한 최근 방법들은 accuracy and inference time 간의 trade-off에 대해 우리 연구만큼 집중하진 않는다.
그들은 이 Compromise(타협점, 절충안)에 있어서 경쟁력이 없다.
ViT image classifier의 저자들은 traditional ResNet-50 위에 transformer layer를 쌓는 실험을 진행했다.
이 경우 ResNet은 transformer layer를 위한 feature extractor로 작동하며,
Gradient는 두 Network를 통해 propagate될 수 있다.
그러나 그들의 실험에서는 transformer layer의 수가 고정되어 있다. (e.g. 12 layers for ViT-Base)
이 subsection에서는,
유사한 computiational budget 내에서 Transformer와 CNN을 혼합하는 가능성을 조사한다:
우리는 convolutional stage와 transformer layer 수를 변화시킬 때 얻어지는 trade-off를 탐구했다.
우리의 목표는 실행 시간을 제어하면서 convolution과 transformer hybrid의 variations(변형)을 평가하는 것이다.
Table 1에 결과를 요약했다.
grafted architecture는 DeiT와 ResNet-50 단독 사용보다 더 나은 결과를 보여준다.
smallest number of parameters와 best accuracy는 ResNet-50의 두 stage를 사용한 경우에 나타나는데,
이는 ConvNet의 큰 세 번째 stage를 제외하기 때문이다.
이 실험에서 setting은 DeiT와 유사하다 : 300 epoch 동안 training, ImageNet에서 top-1 validation accuracy를 측정하며, GPU가 초당 처리할 수 있는 image 수로 speed를 측정.
흥미로운 관찰 중 하나는 Figure 3에서 보이는 것처럼,
grafted model의 training convergence가 초기 epoch에서는 convnet과 유사하고,
이후에는 DeiT-S와 유사한 convergence 속도로 전환된다는 것이다.
hypothesis 중 하나는 conv layer가 초기 Layer에서 low-level information을 더 효율적으로 학습할 수 있는 능력이 있다는 것이다.
이는 강력한 Inductive bias, 특히 translation invariance 덕분이다.
이들은 의미 있는 Patch embedding에 빠르게 의존하며,
이는 초기 epoch 동안의 faster convergence를 설명할 수 있다.
LeViT는 ViT architecture와 DeiT training method를 기반으로 하며,
convolution architecture에서 유용한 components를 통합한다.
첫 번째 step은 compatible(호환 가능한) representation을 얻는 것이다.
classification embedding의 역할을 제외하고,
ViT는 activation map을 처리하는 layer stack이다.
실제로, intermediate "token" embedding은
FCN architecture(BCHW 형식)에서의 전통적인 activation maps으로 볼 수 있다.
따라서 activation map에 적용되는 operations(pooling, convolution)은
DeiT의 intermediate representation에도 적용될 수 있다.
이 연구에서는 parameter수를 최소화하는 것이 아니라 computation을 최적화하는 데 초점을 맞춘다.
ResNet family가 VGG network보다 더 효율적인 design decisions 중 하나는
처음 두 stages에서 상대적으로 적은 computation budget으로 강력한 resolution reduction을 적용하는 것이다.
activation map이 ResNet의 big third stage에 도달할 때쯤, resolution은 이미 축소되어
convolution이 작은 activation map에 적용되므로 computational cost가 줄어든다.
Section 3에서 preliminary analysis는
small convnet을 transformer stack의 input에 적용할 때 accuracy가 향상될 수 있음을 보여줬다.
LeViT에서는 input에 4개의 conv layer(stride 2)를 적용하여
resolution 축소를 수행하기로 결정했다.channel수는 으로 증가한다.
이는 중요한 정보를 잃지 않으면서 transformer의 하위 layer로 들어가는 activation map input을 축소한다.
LeViT-256을 위한 patch extractor는
image shape 를 로 변환하여 184MFLOPs를 소모한다.
(비교를 위해 ResNet-18의 처음 10개 layer는 동일한 dimensionality reduction를 1042MFLOPs로 수행한다.)
ViT architecture의 FC layer는 conv와 동일하다.
ViT는 각 atetention and MLP unit 이전에 LayerNorm을 적용하는 반면,
LeViT는 각 convolution 후에 BN을 수행한다.
[54]에 따라,
residual connection과 결합되는 BatchNorm의 weight parameter를 0으로 initialized한다.
inference를 위해 BatchNorm을 convolution과 병합하여
LayerNomr 보다 runtime에서의 이점이 된다.
DeiT는 GELU function을 사용했지만,
LeViT의 모든 non-linear activations은 Hardswish이다.
convolutional architectures는 pyramid로 구축되며,
처리 중에 activation maps의 resolution이 줄어들면서 channel 수가 증가한다.
Section 3에서 우리는 ResNet-50 stages를 사용하여 transformer stack을 pre-process했다.
LeViT는 transformer architecture 내에 ResNet stages를 통합한다.
stage 내부의 architecture는 visual transformer와 유사하다 :
a residual structure with alternated MLP and activation blocks.
다음으로 우리는 classical set과 비교하여
attention blocks(Figure 5)의 modifications을 review할 것이다.
positional embedding은 attention block sequence의 input에만 포함된다.
따라서 positional encoding이 상위 layer에서도 중요하기 때문에,
이는 intermediate representations에서도 유지되며 불필요하게 representation capacity를 사용하게 된다.
따라서 우리의 목표는 각 attention block 내에 positional information을 제공하고,
attention mechanism에 명시적으로 relative position information을 주입하는 것이다 :
우리는 단순히 attention maps에 attention bias를 추가했다.
두 pixel 와 사이의
하나의 head 에 대한 scalar attention value는 다음과 같이 계산된다.
첫 번째 term은 classical attention이다.
두 번째 term은 translation-invariant attention bias이다.
각 head는 서로 다른 pixel offsets에 대응하는 parameter를 갖는다.
differences and $y-y'을 symmetrizing(대칭화)하면
model이 flip invariance를 가지고 학습하도록 유도된다.