首页 > 编程知识 正文

resnet50分类,resnet详解

时间:2023-05-04 22:41:22 阅读:19047 作者:1930

ResNet18的18层表示加权的18层,包括卷积层和全部连接层,不包括池化层和BN层。

Resnet论文所示的结构图

参考ResNet详细解读

结构分析:

首先,在一楼的折叠中使用7777大小的模板,步长为2,填充为3。 然后与BN、ReLU进行最大池。 这些构成了第一部分卷积模块conv1。

还有四个stage。 代码中为make_layer ) )生成stage。 每个stage都有多个模块,每个模块称为构建块。 resnet 18=[ 2,2,2,2 ],有8个构建块。 请注意,他有两种模块BasicBlockBottleneck。 resnet18和resnet34使用的是3358www.Sina.com/,resnet50或更高版本使用的是BasicBlock。 无论BottleneckBasicBlock模块如何,都使用了shortcut connection连接方法。

Bottleneck架构中,主要使用两个3x3的卷积,进行BN,然后语句out =residual在输出上叠加输入xx。 (注意首先定义了residual=x ) ) ) ) ) )。

classbasicblock(nn.module ) :expansion=1def_init_ ) self,inplanes,planes,stride=1,down sample=self () stride(self.bn1=nn.batchnorm2d ) planes ) self.relu=nn.relu ) inplace=true ) self.conV2=conV3x3) planes, planes ) self.bn2=nn.batchnorm2d(planes ) self.down sample=down sample self.stride=stridedefforward (self, x ) : residual=xout=self.con v1 (x ) out=self.bn1 ) out ) out=self.relu ) out=self.conV2 ) out ) out out=residualout=self.relu ) out ) returnout3358www他首先通过1x1卷积将通道数量减少一半,3x3卷积保持通道数量不变,1x1卷积将通道数量增加4倍从总体上看,通过这个模块,频道数会翻倍。

classbottleneck(nn.module ) :expansion=4def_init_ ) self,inplanes,planes,stride=1,down sample=self () kernel_size=1,bias=False ) self.bn1 planes,kernel_size=3,stride=stride,padding=1,bias=False ) sell bias=false (self.bn3=nn.batch norm 2d ) planes*4) self.relu=nn.relu(inplace=true ) () ) ) ) self.down sample=down sample self.stride=stridedefforward (x ) : residual=xout=self.con v1 (x ) out=self.bn1 t=self.conV3(out ) out=self.bn3 ) out ) if self.downsampleisnotnone : residual=self.down sample (x ) out=relf=down

结构图和其他详细信息:

见3https://www.Jian Shu.com/p/085 F4 c 8256 f1

3359 blog.csdn.net/weixin _ 40548136/article/details/88820996

BasicBlock

Bottleneck

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。