当前位置:网站首页>图像恢复论文简记——Uformer: A General U-Shaped Transformer for Image Restoration
图像恢复论文简记——Uformer: A General U-Shaped Transformer for Image Restoration
2022-04-23 05:44:00 【umbrellalalalala】
2021年6月6日提交到arxiv上的文章。ICCV2021的Eformer就是Uformer基础上改进而来,看来还是值得一读,简单记录下。
知乎同名账号同步发布。
一、架构设计
架构如图:
比起普通的UNet,不同之处在于采用了LeWin Transformer,这种Transformer也是本工作的创新点。
所谓LeWin Transformer,就是local-enhanced window Transformer,其中包含W-MSA和LeFF:
- W-MSA:non-overlapping window-based self-attention,作用是减小计算开销(传统transformer是在全局计算self-attention,而它不是);
- LeFF:传统transformer中采用前馈神经网络,不能很好利用local context,LeFF的采用可以capture local information。
️两个创新点:
- 提出LeWin Transformer,引入UNet
- 三种跳跃连接
二、主要模块细节
2.1,W-MSA
这是本工作最大的创新点。 (经提醒,swin Transformer里就有)
首先将将C×H×W的X分为N个C×M×M个patch,每个patch视为有M×M个C维vector(N = H × W / M²),这C个vector就输入W-MSA中。根据上述公式,简单理解就是将X分为不重叠的N片,然后对每一片进行self-attention的计算即可。
作者表示,虽说是在一片上进行self-attention的计算,但是在UNet的encode阶段,由于下采样的存在,所以在这一片上计算自注意力,对应在下采样前更大感受野上计算自注意力。
采用了relative position encoding,所以计算公式可以表示为:
这种位置编码的引用[48,41]分别是:
[48] Peter Shaw, Jakob Uszkoreit, and Ashish Vaswani. Self-attention with relative position repre-
sentations. arXiv preprint arXiv:1803.02155, 2018.
[41] Ze Liu, Yutong Lin, Yue Cao, Han Hu, Yixuan Wei, Zheng Zhang, Stephen Lin, and Baining
Guo. Swin transformer: Hierarchical vision transformer using shifted windows. arXiv preprint
arXiv:2103.14030, 2021.
2.2,LeFF
LeFF是Incorporating Convolution Designs into Visual Transformers
发明的,其中的Convolution-enhanced image Transformer (CeiT)
包含了这个设计。
精髓在于对self-attention计算模块输出的N个token(vector),重新排列为 N × N \sqrt{N} \times \sqrt{N} N×N的“image”,然后进行depth-wise的卷积操作。看完CeiT作者给出的图解,再看Uformer作者给出的图解,就不难理解含义了:
每个线性层/卷积层之后,用的都是GELU激活函数。
(depth-wise的卷积网上一搜就有,作用是减少参数,提升计算速度)
2.3,三种跳跃连接
UNet架构是有跳跃连接的,在本工作中就是将encoder部分的Transformer的输出传递到decoder部分,但是利用这些跳跃连接传递的信息的方式有很多种,作者探索了三种:
- 第一种是直接concat过来;
- 第二种是:每一个decode stage有一个上采样和两个Transformer block,意思是第一个用self-attention,第二个用cross attention;
- 第三种是concat的信息作为key和value的cross attention。
作者认为三种差不多,但第一种好一点点,所以采用第一种作为Uformer的默认设置。
Uformer的架构设计细节就在这,其他内容不细看了。
三、计算开销
既然LeWin Transformer中的W-MSA主打减小计算开销,那么自然要看下算法复杂度:
给定feature map X,维度为C×H×W,如果是传统的self-attention,那么复杂度为 O ( H 2 W 2 C ) O(H^2 W^2 C) O(H2W2C),分割为M×M的patch再做self-attention,则是 O ( H W M 2 M 4 C ) = O ( M 2 H W C ) O(\frac{HW}{M^2}M^4 C)=O(M^2HWC) O(M2HWM4C)=O(M2HWC),复杂度有所减少。
四、实验结果
作者做了去噪、去雨、去模糊的实验。
版权声明
本文为[umbrellalalalala]所创,转载请带上原文链接,感谢
https://blog.csdn.net/umbrellalalalala/article/details/122341126
边栏推荐
- Latex快速入门
- JSP语法及JSTL标签
- Pytorch——数据加载和处理
- Anaconda
- PyQy5学习(二):QMainWindow+QWidget+QLabel
- Font shape `OMX/cmex/m/n‘ in size <10.53937> not available (Font) size <10.95> substituted.
- JDBC连接数据库
- Conda 虚拟环境管理(创建、删除、克隆、重命名、导出和导入)
- 你不能访问此共享文件夹,因为你组织的安全策略阻止未经身份验证的来宾访问
- Pytorch learning record (XI): data enhancement, torchvision Explanation of various functions of transforms
猜你喜欢
多线程与高并发(1)——线程的基本知识(实现,常用方法,状态)
图解HashCode存在的意义
Pytorch学习记录(七):处理数据和训练模型的技巧
数字图像处理基础(冈萨雷斯)一
Navicate连接oracle(11g)时ORA:28547 Connection to server failed probable Oeacle Net admin error
opensips(1)——安装opensips详细流程
SQL注入
Getting started with JDBC \ getting a database connection \ using Preparedstatement
建表到页面完整实例演示—联表查询
解决报错:ImportError: IProgress not found. Please update jupyter and ipywidgets
随机推荐
io.lettuce.core.RedisCommandExecutionException: ERR wrong number of arguments for ‘auth‘ command
数据处理之Numpy常用函数表格整理
Conda 虚拟环境管理(创建、删除、克隆、重命名、导出和导入)
The user name and password of users in the domain accessing the samba server outside the domain are wrong
Pytorch学习记录(五):反向传播+基于梯度的优化器(SGD,Adagrad,RMSporp,Adam)
Get the value of state in effects in DVA
Pytorch学习记录(四):参数初始化
多个一维数组拆分合并为二维数组
Latex快速入门
Pytorch学习记录(七):处理数据和训练模型的技巧
PyQy5学习(三):QLineEdit+QTextEdit
POI generates excel and inserts pictures
mysql-触发器、存储过程、存储函数
MySQL transaction
关于二叉树的遍历
Rsync for file server backup
Pytorch learning record (XII): learning rate attenuation + regularization
DBCP使用
Manually delete registered services on Eureka
The list attribute in the entity is empty or null, and is set to an empty array