Convolutional Neural Networks (CNNs) have dominated computer vision for years, due to its ability in capturing locality and translation invariance. Recently, many vision transformer architectures have been proposed and they show promising performance. A key component in vision transformers is the fully-connected self-attention which is more powerful than CNNs in modelling long range dependencies. However, since the current dense self-attention uses all image patches (tokens) to compute attention matrix, it may neglect locality of images patches and involve noisy tokens (e.g., clutter background and occlusion), leading to a slow training process and potentially degradation of performance. To address these problems, we propose a sparse attention scheme, dubbed k-NN attention, for boosting vision transformers. Specifically, instead of involving all the tokens for attention matrix calculation, we only select the top-k similar tokens from the keys for each query to compute the attention map. The proposed k-NN attention naturally inherits the local bias of CNNs without introducing convolutional operations, as nearby tokens tend to be more similar than others. In addition, the k-NN attention allows for the exploration of long range correlation and at the same time filter out irrelevant tokens by choosing the most similar tokens from the entire image. Despite its simplicity, we verify, both theoretically and empirically, that $k$-NN attention is powerful in distilling noise from input tokens and in speeding up training. Extensive experiments are conducted by using ten different vision transformer architectures to verify that the proposed k-NN attention can work with any existing transformer architectures to improve its prediction performance.
翻译:多年来,由于能够捕捉地点和翻译差异, Convolution Neal Network (CNNs) 一直主导着计算机视野。 最近,许多视觉变压器结构被提出来,它们表现出有希望的性能。 视觉变压器中的一个关键组成部分是完全连接的自我注意,在模拟长期依赖性关系时比CNN更强大。 然而,由于当前密度浓厚的自我注意使用所有图像补丁(tokes)来计算关注矩阵,因此它可能忽视图像补丁的位置,并涉及噪音的象征(例如,模糊的背景和隐蔽),导致培训进程缓慢,并可能出现业绩退化。为了解决这些问题,我们提出了一种微弱的注意机制,即完全连接的自我注意机制,即完全连接的自我注意。 具体地说,我们只从键中选择了每个调控点的顶级的类似符号(tokets) 来计算注意地图。 拟议的 k-NNNE 将本地的偏重度继承了CNN的偏向,而没有引入革命性的动作,因为近处的加速的变压过程往往选择其直观的直观, 直观性的直观性的图像在模拟的模拟中进行。 平等的模拟的模拟的模拟的模拟的模拟的模拟的模拟的模拟的模拟的模拟的模拟中, 。