arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2103.00112cs.CVcs.AI
收藏

Transformer中的Transformer

Transformer in Transformer

ISCAS(中国科学院软件研究所);UCAS(中国科学院大学);Huawei Technologies(华为技术有限公司);University of Macau(澳门大学)

Kai Han, An Xiao, Enhua Wu, Jianyuan Guo, Chunjing Xu, Yunhe Wang

摘要:

Transformer是一种新型的神经结构,它通过注意力机制将输入数据编码为强大的特征。基本上,视觉转换器首先将输入图像划分为几个局部块,然后计算表示及其关系。由于自然图像具有高度的复杂性和丰富的细节和颜色信息,块划分的粒度不够细,以挖掘不同尺度和位置的对象的特征。在本文中,我们指出,这些本地补丁内的注意力也是必不可少的,以建设高性能的视觉变压器,我们探索了一种新的架构,即Transformer IN Transformer(TNT)。具体来说,我们认为本地补丁(例如,16 $\times$ 16)作为"视觉句子"并呈现以进一步将它们划分成更小的块(例如,4 $\times$ 4)作为"视觉词"。每个单词的注意力将与给定视觉句子中的其他单词一起计算,计算成本可以忽略不计。将单词和句子的特征聚合起来,以增强表示能力。在多个基准测试上的实验证明了所提出的TNT架构的有效性,例如,我们在ImageNet上实现了81.5%的top-1准确率,这比具有类似计算成本的最先进的视觉Transformer高出约1.7%。PyTorch代码可以在https://github.com/huawei-noah/CV-Backbones上获得,MindSpore代码可以在www.example.com上获得。

英文摘要:

Transformer is a new kind of neural architecture which encodes the input data as powerful features via the attention mechanism. Basically, the visual transformers first divide the input images into several local patches and then calculate both representations and their relationship. Since natural images are of high complexity with abundant detail and color information, the granularity of the patch dividing is not fine enough for excavating features of objects in different scales and locations. In this paper, we point out that the attention inside these local patches are also essential for building visual transformers with high performance and we explore a new architecture, namely, Transformer iN Transformer (TNT). Specifically, we regard the local patches (e.g., 16$\times$16) as "visual sentences" and present to further divide them into smaller patches (e.g., 4$\times$4) as "visual words". The attention of each word will be calculated with other words in the given visual sentence with negligible computational costs. Features of both words and sentences will be aggregated to enhance the representation ability. Experiments on several benchmarks demonstrate the effectiveness of the proposed TNT architecture, e.g., we achieve an 81.5% top-1 accuracy on the ImageNet, which is about 1.7% higher than that of the state-of-the-art visual transformer with similar computational cost. The PyTorch code is available at https://github.com/huawei-noah/CV-Backbones, and the MindSpore code is available at https://gitee.com/mindspore/models/tree/master/research/cv/TNT.

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

↑