当前位置:网站首页>当CNN遇见Transformer《CMT:Convolutional Neural Networks Meet Vision Transformers》
当CNN遇见Transformer《CMT:Convolutional Neural Networks Meet Vision Transformers》
2022-07-28 17:23:00 【我是大黄同学呀】
原文地址
论文阅读方法
初识
ViT直接将Transformer架构用于视觉,依附于大数据集上的预训练,达到了不错的效果。并且后续也出现大量优秀的改进工作,展现了transformer不凡的性能,但还是弱于相同尺寸的CNN(比如EfficientNet)。
作者认为虽然标准的transformer能够捕获到patch间的长距离依赖关系,但相比于NLP任务,视觉任务中的2D结构,以及patch间的局部空间信息也非常重要。此外,transformer由于固定的尺寸,因此其很难去捕获低分辨率、多尺度的特征,这对密集预测任务非常不利(分割、检测)。而且transformer的self-attention模块对于输入图像分辨率的时间、空间复杂度都是O( N 2 C N^2C N2C),而卷积神经网络为O( N C 2 NC^2 NC2)。
N表示序列长度,C表示维度。
本文的目的就是将CNN的优点结合到Transformer中,以解决上述问题。从而提出了一个全新的架构CMT,引入卷积操作进行细粒度特征提取,此外引入层级结构(stage-wise)用于提取多尺度特征并降低计算消耗,同时也设计了一些特殊的组件提取局部以及全局特征。最后在不同的数据集上进行实验,即提高了性能,也降低计算损耗。
相知
核心技术
此节忽略了Scaling策略和计算复杂度的比较,大家有兴趣可以参考原文。

上图中,(a)为CNN中经典的ResNet网络,(b)为目前的视觉ViT结构。可以看到ViT直接将输入图像切成不重叠的patch然后进行线性映射,这样直接失去了patch中的2维空间特征。因此CMT采用stem结构,用3x3卷积下采样以及提取局部特征。此外,为了提取到多尺度特征采用stage结构,因此每个stage前均使用2x2卷积+LayerNorm进行下采样和升维度(channel x 2)。在每个stage内,构建一系列的CMT模块提取特征,它既能捕获局部性能,也能捕获长距离依赖关系。下面详细介绍下每个block内的细节:
① LPU,local perception unit局部感知单元:

旋转和平移是CNN中常用的增广方法,用于增加模型的平移不变性。然而在ViT中通常采用绝对位置编码,每个patch都对应一个唯一位置编码,因此无法通过数据增广引入平移不变性,也同时忽略了局部相关性和结构信息。因此LPU采用3x3的深度分离卷积+残差连接进一步提取局部特征。
② LMHSA,lightweight multi-head self-attention轻量级多头注意力:

原始的self-attention操作如下:

而LMHSA会先用步长为K的KxK深度卷积减少K与V的空间维度(变为 n k 2 × d k \frac{n}{k^2}\times d_k k2n×dk),并且增加了可学习的偏置项B:

③ IRFFN,inverted residual feed-forward network反向残差前馈网络

这个模块类似于mobilenetv2中的inverted residual模块(两头窄中间宽的通道维度设计),只是改变了残差连接的位置以及使用的是GELU作为激活函数。

最后,作者设计了几种不同的网络架构,有点类似于ResNet与Efficient的结合:
实验结果
实验只附上在ImageNet上的结果,关于消融实验和transfer任务这里不提及。

上图对比了相似精度下的CNN和transformer方法,可以看到CMT在性能提升的基础上,还保持较少的参数量和计算消耗。还有值得注意的一点是,之前所有基于transformer的方法性能均不如efficientnet,而CMT超越了efficientnet,并且计算损耗更低。
回顾
CMT为华为诺亚方舟实验室出品,文章分析了transformer模型在视觉任务上的弊端:1. 损失了空间局部结构信息;2. 参数量大、计算量大;3. 无法提取细粒度特征、多尺度特征。而这些方面CNN做得很好,因此作者将CNN网络的一些经典设计引入到transformer中,并且加入卷积模块,提升效率和性能,比如:ResNet的残差结构、Mobilenet中的depth-wise卷积、efficient中的参数Scaling策略等等。
虽然整篇文章在方法上并没有太高的学术创新,更多偏向工程化的网络设计,但这无疑推动了transformer在CV领域的落地进展,毕竟谁会拒绝一个又快又好的模型呢。
代码
目前官方代码并无开源,但github已经有很多优秀的复现工作,贴上一份:
https://github.com/FlyEgle/CMT-pytorch
边栏推荐
- The wechat installation package has expanded 575 times in 11 years, and the up owner: "98% of the documents are garbage"; Apple App store was exposed to a large number of pornographic apps; Four techn
- DevCon.exe 导出output至指定文件
- unity CS1513
- 2、 Uni app login function page Jump
- JDBC简单封装
- RFs self study notes (III): clutter model - first determine the number with Poisson distribution, and then use uniform distribution as probability distribution
- Structure and working principle of thyristor
- Pytest custom hook function
- How new people get started learning software testing
- The difference between --save Dev and --save in NPM
猜你喜欢
![[machine learning] support vector machine classification](/img/6d/e4fb9b5bf82362edcebbf366f9b73e.png)
[machine learning] support vector machine classification

BM16 删除有序链表中重复的元素-II

vim学习手册

Fundamentals of software testing and development | practical development of several tools in testing and development

Creating new projects and adding your own programs

QT user defined control user guide (flying Qingyun)
![[physical application] atmospheric absorption loss with matlab code](/img/72/e6ac23012a59ac48a37bcbb068890b.png)
[physical application] atmospheric absorption loss with matlab code

Using CPLEX to solve small-scale energy-efficient FJSP

Pytest custom hook function

The open source of "avoiding disease and avoiding medicine" will not go far
随机推荐
How much is software testing training generally?
PyG搭建异质图注意力网络HAN实现DBLP节点预测
QT function optimization: QT 3D gallery
Is it easy to learn the zero foundation of software testing?
架构实战营第8模块作业
Learn from Li Mu, deep learning - linear regression and basic optimization function
About ASM redundancy
Is the software testing training institution reliable?
What does real HTAP mean to users and developers?
pytest 自定义HOOK函数
Is there any prospect and way out for software testing?
Wechat official account custom sharing and updateappmessagesharedata are all successful. Why is it a link that is shared?
Interpretation of ue4.25 slate source code
Learn from Li Mu in depth -softmax return
Youqilin system installation beyondcomare
Module 8 of the construction camp
The open source of "avoiding disease and avoiding medicine" will not go far
BM16 delete duplicate elements in the ordered linked list -ii
The login interface of modern personal blog system modstartblog v5.4.0 has been revised and the contact information has been added
OAI L3 and L2 interface analysis