arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2307.02092cs.LGcs.CV
收藏

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

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

Shanghai University of Electric Power(上海电力大学);Midea Group(美的集团)

Qiqi Zhou, Yichen Zhu

AI总结:

本文提出通过自适应分配每张图像的最优令牌长度来加速视觉Transformer推理,利用ReViT提取最少令牌标签并训练轻量级TLA分配器,在保持准确性的同时显著降低计算成本。

摘要:

视觉Transformer是一种将每张图像分解为固定长度令牌序列,并以类似于自然语言处理中处理单词的方式处理这些令牌的模型。尽管增加令牌数量通常会带来更好的性能,但它也会导致计算成本的大幅增加。受“一图胜千言”这一说法的启发,我们提出了一种通过缩短长图像来加速ViT模型的创新方法。具体而言,我们引入了一种在测试时为每张图像自适应分配令牌长度以加速推理速度的方法。首先,我们训练一个可调整尺寸的ViT(ReViT)模型,使其能够处理具有不同令牌长度的输入。接下来,我们从ReViT中提取令牌长度标签,这些标签指示实现准确预测所需的最少令牌数量。然后,我们使用这些标签训练一个轻量级的令牌长度分配器(TLA),在推理过程中为每张图像分配最优的令牌长度。TLA使ReViT能够以最少且足够的令牌数量处理图像,从而减少ViT模型中的令牌数量并提高推理速度。我们的方法具有通用性,并且与现代视觉Transformer架构兼容,能够显著降低计算成本。我们在图像分类和动作识别任务上,通过多个具有代表性的ViT模型验证了我们方法的有效性。

英文摘要:

The vision transformer is a model that breaks down each image into a sequence of tokens with a fixed length and processes them similarly to words in natural language processing. Although increasing the number of tokens typically results in better performance, it also leads to a considerable increase in computational cost. Motivated by the saying "A picture is worth a thousand words," we propose an innovative approach to accelerate the ViT model by shortening long images. Specifically, we introduce a method for adaptively assigning token length for each image at test time to accelerate inference speed. First, we train a Resizable-ViT (ReViT) model capable of processing input with diverse token lengths. Next, we extract token-length labels from ReViT that indicate the minimum number of tokens required to achieve accurate predictions. We then use these labels to train a lightweight Token-Length Assigner (TLA) that allocates the optimal token length for each image during inference. The TLA enables ReViT to process images with the minimum sufficient number of tokens, reducing token numbers in the ViT model and improving inference speed. Our approach is general and compatible with modern vision transformer architectures, significantly reducing computational costs. We verified the effectiveness of our methods on multiple representative ViT models on image classification and action recognition.

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

↑