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

使长图像变短:用于视觉Transformer的自适应令牌长度

Make A Long Image Short: Adaptive Token Length for Vision Transformers

Midea Group, AI Innovation Center(美的集团人工智能创新中心);Tongji University(同济大学)

Yichen Zhu, Yuqin Zhu, Jie Du, Yi Wang, Zhicai Ou, Feifei Feng, Jian Tang

摘要:

视觉Transformer将每个图像分割成具有固定长度的标记序列,并以与自然语言处理中的单词相同的方式处理标记。更多的令牌通常会带来更好的性能,但会大大增加计算成本。受谚语“一张图片胜过千言万语”的启发,我们的目标是通过缩短长图像来加速ViT模型。为此,我们提出了一种新的方法来分配令牌长度自适应推理。具体来说,我们首先训练一个ViT模型,称为Resizable-ViT(ReViT),它可以处理具有不同令牌长度的任何给定输入。然后,我们从ReViT中检索“令牌长度标签”,并使用它来训练轻量级令牌长度分配器(TLA)。标记长度标签是ReViT可以做出正确预测的分割图像的最小标记数量,并且TLA被学习以基于这些标签分配最佳标记长度。TLA使ReViT能够在推理过程中使用最少的足够数量的标记来处理图像。因此,通过减少ViT模型中的令牌数量来提高推理速度。我们的方法是通用的,与现代视觉Transformer架构兼容,可以显着减少计算开销。我们在两个任务(图像分类和动作识别)中验证了我们的方法在多个代表性ViT模型(DeiT,LV-ViT和TimesFormer)上的有效性。

英文摘要:

The vision transformer splits each image into a sequence of tokens with fixed length and processes the tokens in the same way as words in natural language processing. More tokens normally lead to better performance but considerably increased computational cost. Motivated by the proverb "A picture is worth a thousand words" we aim to accelerate the ViT model by making a long image short. To this end, we propose a novel approach to assign token length adaptively during inference. Specifically, we first train a ViT model, called Resizable-ViT (ReViT), that can process any given input with diverse token lengths. Then, we retrieve the "token-length label" from ReViT and use it to train a lightweight Token-Length Assigner (TLA). The token-length labels are the smallest number of tokens to split an image that the ReViT can make the correct prediction, and TLA is learned to allocate the optimal token length based on these labels. The TLA enables the ReViT to process the image with the minimum sufficient number of tokens during inference. Thus, the inference speed is boosted by reducing the token numbers in the ViT model. Our approach is general and compatible with modern vision transformer architectures and can significantly reduce computational expanse. We verified the effectiveness of our methods on multiple representative ViT models (DeiT, LV-ViT, and TimesFormer) across two tasks (image classification and action recognition).

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

↑