当前位置:网站首页>Basics of ResNet: Principles of Residual Blocks
Basics of ResNet: Principles of Residual Blocks
2022-07-31 17:48:00 【GIS and Climate】
在深度学习中,In order to enhance the learning ability of the model,The network layer will get deeper and deeper,但是随着深度的增加,It also brings up some comparison problems,主要包括:
Model complexity increases,Network training is difficult; 梯度消失/梯度爆炸 网络退化,That is to say, the learning ability of the model has reached saturation,Increasing the number of network layers does not improve accuracy anymore.
为了解决网络退化问题,He Kaiming proposed a deep residual network,It can be said that it is a very large creative work in deep learning.
残差网络
The idea of residual network is to map the network learned fromX到YSwitch to learning fromX到Y-X的差,Then add the learned residual information to the original output.even in extreme cases,This residual is0,Then the network is oneX到Y的恒等映射.其示意图如下:

In the structure of the above figure, the main line is actually no different from the normal network structure,The difference is the connecting line on the right,作者称之为Shortcut Connection,This means that some network layers are skipped and directly connected to the output of a subsequent layer.
优势
in the residual network,Because the residual block preserves the information of the original input,So the network has the following advantages:
随着深度的增加,Higher precision can be obtained,Because the residual error of its learning is more accurate; Network optimization is relatively simple; 比较通用;
残差块的实现
Follow the structure shown in the figure above,在PytorchIt is also very simple to implement a residual block in ,It is nothing more than adding one to the traditional networkshortcut connection,For example, a most basic residual block code is as follows:
class ResidualBlock(nn.Module):
def __init__(self, channels):
super(ResidualBlock, self).__init__()
self.conv1 = nn.Conv2d(channels, channels, kernel_size=3, padding=1)
self.bn1 = nn.BatchNorm2d(channels)
self.prelu = nn.PReLU()
self.conv2 = nn.Conv2d(channels, channels, kernel_size=3, padding=1)
self.bn2 = nn.BatchNorm2d(channels)
def forward(self, x):
residual = self.conv1(x)
residual = self.bn1(residual)
residual = self.prelu(residual)
residual = self.conv2(residual)
residual = self.bn2(residual)
out = self.prelu(x + residual)
return out
One is achieved through the above codeThe most basic residual block(It is only implemented according to the picture,It's not the same as the original).需要注意的地方有:
The residual block is because in forwardThe end of the function needs to be the inputxand the learned residuals(也就是 )相加,So the dimensions of the two tensors should be exactly the same; 在最后将 After the addition, enter the activation function; Each convolutional layer is followed by a batch normalization layer.
在真正用的时候,The code above needs to be further complicated,For example, whether to downsample the data, etc,But understand the basics above,就可以自己进行相应的修改,to apply to your own network.
参考
【1】HE K, ZHANG X, REN S, et al. Deep Residual Learning for Image Recognition[C]//2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR).2016:770-778. 10.1109/CVPR.2016.90.
【2】https://towardsdev.com/implement-resnet-with-pytorch-a9fb40a77448
边栏推荐
- 架构师04-应用服务间加密设计和实践
- 【码蹄集新手村600题】通向公式与程序相结合
- Bika LIMS open source LIMS set - use of SENAITE (detection process)
- 【AcWing】第 62 场周赛 【2022.07.30】
- Masterless Replication System (3)-Limitations of Quorum Consistency
- 京东获取商品历史价格信息 API
- adb shell error error: device unauthorized
- Mariabackup实现Mariadb 10.3的增量数据备份
- Cache and Database Consistency Solutions
- 浅谈网络安全之算法安全
猜你喜欢
Huawei mobile phone one-click to open "maintenance mode" to hide all data and make mobile phone privacy more secure
Unity 之 音频类型和编码格式介绍
Huawei's top engineers lasted nine years "anecdotal stories network protocol" PDF document summary, is too strong
组合学笔记(六)局部有限偏序集的关联代数,Möbius反演公式
flyway的快速入门教程
Golang go-redis cluster模式下不断创建新连接,效率下降问题解决
MySQL---多表查询
最新神作!阿里巴巴刚出炉的面试参考指南(泰山版),我直接狂刷29天
go基础部分学习笔记记录
程序员如何学习开源项目,这篇文章告诉你
随机推荐
After Effects 教程,如何在 After Effects 中调整过度曝光的快照?
ECCV 2022 华科&ETH提出首个用于伪装实例分割的一阶段Transformer的框架OSFormer!代码已开源!...
Flutter set the background color of the statusbar status bar and APP method (AppBar) internal consistent color.
mysql的备份表的几种方法
A common method and the use of selenium
MySQL---创建和管理数据库和数据表
[TypeScript] OOP
Write a database document management tool based on WPF repeating the wheel (1)
多数据中心操作和检测并发写入
多主复制下处理写冲突(1)-同步与异步冲突检测及避免冲突
Flex布局详解
多线程之锁
研发过程中的文档管理与工具
GP 6 overall architecture study notes
【luogu P8326】Fliper(图论)(构造)(欧拉回路)
【Yugong Series】July 2022 Go Teaching Course 021-Slicing Operation of Go Containers
保证接口数据安全的10种方式
AcWing 1282. Search Keyword Problem Solution ((AC Automata) Trie+KMP)+bfs)
关于柱状图的经典画法总结
架构师04-应用服务间加密设计和实践