arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2202.07800cs.CVcs.LG
收藏

并非所有补丁都是您需要的:通过令牌重组加速视觉Transformer

Not All Patches are What You Need: Expediting Vision Transformers via Token Reorganizations

UC San Diego(加州大学圣迭戈分校);The University of Hong Kong(香港大学);Tencent AI Lab(腾讯人工智能实验室)

Youwei Liang, Chongjian Ge, Zhan Tong, Yibing Song, Jue Wang, Pengtao Xie

摘要:

视觉Transformer(ViTs)以图像块为标记,在图像块之间构造多头自注意(MHSA)。完全利用这些图像标记会带来冗余计算,因为并非所有标记都在MHSA中被注意到。例如,包含语义上无意义或分散注意力的图像背景的令牌对ViT预测没有积极贡献。在这项工作中,我们建议在ViT模型的前馈过程中重新组织图像标记,并在训练过程中将其集成到ViT中。对于每个前向推理,我们识别MHSA和FFN之间的注意图像标记(即,前馈网络)模块,这是由相应的类令牌注意引导的。然后,我们重新组织图像令牌,通过保留注意的图像令牌和融合不注意的,以加快后续的MHSA和FFN计算。为此,我们的方法EVIT从两个角度提高了ViTs。首先,在相同数量的输入图像令牌下,我们的方法减少了MHSA和FFN的计算,以实现高效的推理。例如,DeiT-S的推理速度提高了50%,而ImageNet分类的识别准确率仅下降了0.3%。其次,通过保持相同的计算成本,我们的方法使ViTs能够将更多的图像标记作为输入,以提高识别精度,其中图像标记来自更高分辨率的图像。一个例子是,我们将DeiT-S的识别准确率提高了1%,而计算成本与普通DeiT-S相同。同时,我们的方法没有引入更多的参数的ViTs。在标准基准测试上的实验表明了该方法的有效性。代码可在https://github.com/youweiliang/evit上获得

英文摘要:

Vision Transformers (ViTs) take all the image patches as tokens and construct multi-head self-attention (MHSA) among them. Complete leverage of these image tokens brings redundant computations since not all the tokens are attentive in MHSA. Examples include that tokens containing semantically meaningless or distractive image backgrounds do not positively contribute to the ViT predictions. In this work, we propose to reorganize image tokens during the feed-forward process of ViT models, which is integrated into ViT during training. For each forward inference, we identify the attentive image tokens between MHSA and FFN (i.e., feed-forward network) modules, which is guided by the corresponding class token attention. Then, we reorganize image tokens by preserving attentive image tokens and fusing inattentive ones to expedite subsequent MHSA and FFN computations. To this end, our method EViT improves ViTs from two perspectives. First, under the same amount of input image tokens, our method reduces MHSA and FFN computation for efficient inference. For instance, the inference speed of DeiT-S is increased by 50% while its recognition accuracy is decreased by only 0.3% for ImageNet classification. Second, by maintaining the same computational cost, our method empowers ViTs to take more image tokens as input for recognition accuracy improvement, where the image tokens are from higher resolution images. An example is that we improve the recognition accuracy of DeiT-S by 1% for ImageNet classification at the same computational cost of a vanilla DeiT-S. Meanwhile, our method does not introduce more parameters to ViTs. Experiments on the standard benchmarks show the effectiveness of our method. The code is available at https://github.com/youweiliang/evit

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑