当前位置:网站首页>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
边栏推荐
- Mariabackup implements incremental data backup for Mariadb 10.3
- Go basic part study notes
- MySQL---运算符
- MySQL - single function
- 京东获取商品历史价格信息 API
- 几款永久免费内网穿透,好用且简单(内网穿透教程)
- Huawei's top engineers lasted nine years "anecdotal stories network protocol" PDF document summary, is too strong
- 如何识别假爬虫?
- 手把手教你学会部署Nestjs项目
- 20.支持向量机—数学原理知识
猜你喜欢

【网络通信三】研华网关Modbus服务设置

中文编码的设置与action方法的返回值

Golang 小数操作之判断几位小数点与四舍五入

【pytorch】1.7 pytorch与numpy,tensor与array的转换

【码蹄集新手村600题】不通过字符数组来合并俩个数字

基于WPF重复造轮子,写一款数据库文档管理工具(一)

Intelligent bin (9) - vibration sensor (raspberries pie pico implementation)
![[pytorch] pytorch automatic derivation, Tensor and Autograd](/img/99/c9632a7d3f70a13e1e26b9aa67b8b9.png)
[pytorch] pytorch automatic derivation, Tensor and Autograd

adb shell error error: device unauthorized

学生管理系统第一天:完成登录退出操作逻辑 PyQt5 + MySQL5.8
随机推荐
go mode tidy出现报错go warning “all“ matched no packages
组合学笔记(六)局部有限偏序集的关联代数,Möbius反演公式
Automated testing - web automation - first acquaintance with selenium
如何识别假爬虫?
After Effects tutorial, How to adjust overexposed snapshots in After Effects?
A common method and the use of selenium
MySQL---Create and manage databases and data tables
抖音根据关键词取视频列表 API
Golang——从入门到放弃
【luogu P8326】Fliper(图论)(构造)(欧拉回路)
BOW/DOM(上)
Last write wins (discards concurrent writes)
【愚公系列】2022年07月 Go教学课程 022-Go容器之字典
MySQL---sort and pagination
Multi-datacenter operation and detection of concurrent writes
go基础部分学习笔记记录
关于柱状图的经典画法总结
Handling Write Conflicts under Multi-Master Replication (1)-Synchronous and Asynchronous Conflict Detection and Conflict Avoidance
常用的安全渗透测试工具(渗透测试工具)
Golang go-redis cluster模式下不断创建新连接,效率下降问题解决