当前位置: 首页 > news >正文

写作网站好吗网上做代销上哪个网站

写作网站好吗,网上做代销上哪个网站,wordpress 改cms,google优化排名ResNet在《Deep Residual Learning for Image Recognition》论文中提出#xff0c;是在CVPR 2016发表的一种影响深远的网络模型#xff0c;由何凯明大神团队提出来#xff0c;在ImageNet的分类比赛上将网络深度直接提高到了152层#xff0c;前一年夺冠的VGG只有19层。Image…ResNet在《Deep Residual Learning for Image Recognition》论文中提出是在CVPR 2016发表的一种影响深远的网络模型由何凯明大神团队提出来在ImageNet的分类比赛上将网络深度直接提高到了152层前一年夺冠的VGG只有19层。ImageNet的目标检测以碾压的优势成功夺得了当年识别和目标检测的冠军COCO数据集的目标检测和图像分割比赛上同样碾压夺冠可以说ResNet的出现对深度神经网络来说具有重大的历史意义。 在resnet出现之前网络层数的增加会导致梯度消失或者梯度爆炸 在ResNet网络中有如下几个亮点 1提出residual结构残差结构并搭建超深的网络结构(突破1000层) 2使用Batch Normalization加速训练(丢弃dropout) 残差结构residual 下图是论文中给出的两种残差结构。左边的残差结构是针对层数较少网络例如ResNet18层和ResNet34层网络。 右边是针对网络层数较多的网络例如ResNet101ResNet152等。 为什么深层网络要使用右侧的残差结构呢。因为右侧的残差结构能够减少网络参数与运算量。同样输入、输出一个channel为256的特征矩阵如果使用左侧的残差结构需要大约1170648个参数但如果使用右侧的残差结构只需要69632个参数。明显搭建深层网络时使用右侧的残差结构更合适。 代码 class BasicBlock(nn.Module):expansion 1def __init__(self, in_channel, out_channel, stride1, downsampleNone, **kwargs):super(BasicBlock, self).__init__()self.conv1 nn.Conv2d(in_channelsin_channel, out_channelsout_channel,kernel_size3, stridestride, padding1, biasFalse)self.bn1 nn.BatchNorm2d(out_channel)self.relu nn.ReLU()self.conv2 nn.Conv2d(in_channelsout_channel, out_channelsout_channel,kernel_size3, stride1, padding1, biasFalse)self.bn2 nn.BatchNorm2d(out_channel)self.downsample downsampledef forward(self, x):identity xif self.downsample is not None:identity self.downsample(x)out self.conv1(x)out self.bn1(out)out self.relu(out)out self.conv2(out)out self.bn2(out)out identityout self.relu(out)return outclass Bottleneck(nn.Module):注意原论文中在虚线残差结构的主分支上第一个1x1卷积层的步距是2第二个3x3卷积层步距是1。但在pytorch官方实现过程中是第一个1x1卷积层的步距是1第二个3x3卷积层步距是2这么做的好处是能够在top1上提升大概0.5%的准确率。可参考Resnet v1.5 https://ngc.nvidia.com/catalog/model-scripts/nvidia:resnet_50_v1_5_for_pytorchexpansion 4def __init__(self, in_channel, out_channel, stride1, downsampleNone,groups1, width_per_group64):super(Bottleneck, self).__init__()width int(out_channel * (width_per_group / 64.)) * groupsself.conv1 nn.Conv2d(in_channelsin_channel, out_channelswidth,kernel_size1, stride1, biasFalse) # squeeze channelsself.bn1 nn.BatchNorm2d(width)# -----------------------------------------self.conv2 nn.Conv2d(in_channelswidth, out_channelswidth, groupsgroups,kernel_size3, stridestride, biasFalse, padding1)self.bn2 nn.BatchNorm2d(width)# -----------------------------------------self.conv3 nn.Conv2d(in_channelswidth, out_channelsout_channel*self.expansion,kernel_size1, stride1, biasFalse) # unsqueeze channelsself.bn3 nn.BatchNorm2d(out_channel*self.expansion)self.relu nn.ReLU(inplaceTrue)self.downsample downsampledef forward(self, x):identity xif self.downsample is not None:identity self.downsample(x)out self.conv1(x)out self.bn1(out)out self.relu(out)out self.conv2(out)out self.bn2(out)out self.relu(out)out self.conv3(out)out self.bn3(out)out identityout self.relu(out)return out 完整代码 import torch.nn as nn import torchclass BasicBlock(nn.Module):expansion 1def __init__(self, in_channel, out_channel, stride1, downsampleNone, **kwargs):super(BasicBlock, self).__init__()self.conv1 nn.Conv2d(in_channelsin_channel, out_channelsout_channel,kernel_size3, stridestride, padding1, biasFalse)self.bn1 nn.BatchNorm2d(out_channel)self.relu nn.ReLU()self.conv2 nn.Conv2d(in_channelsout_channel, out_channelsout_channel,kernel_size3, stride1, padding1, biasFalse)self.bn2 nn.BatchNorm2d(out_channel)self.downsample downsampledef forward(self, x):identity xif self.downsample is not None:identity self.downsample(x)out self.conv1(x)out self.bn1(out)out self.relu(out)out self.conv2(out)out self.bn2(out)out identityout self.relu(out)return outclass Bottleneck(nn.Module):注意原论文中在虚线残差结构的主分支上第一个1x1卷积层的步距是2第二个3x3卷积层步距是1。但在pytorch官方实现过程中是第一个1x1卷积层的步距是1第二个3x3卷积层步距是2这么做的好处是能够在top1上提升大概0.5%的准确率。可参考Resnet v1.5 https://ngc.nvidia.com/catalog/model-scripts/nvidia:resnet_50_v1_5_for_pytorchexpansion 4def __init__(self, in_channel, out_channel, stride1, downsampleNone,groups1, width_per_group64):super(Bottleneck, self).__init__()width int(out_channel * (width_per_group / 64.)) * groupsself.conv1 nn.Conv2d(in_channelsin_channel, out_channelswidth,kernel_size1, stride1, biasFalse) # squeeze channelsself.bn1 nn.BatchNorm2d(width)# -----------------------------------------self.conv2 nn.Conv2d(in_channelswidth, out_channelswidth, groupsgroups,kernel_size3, stridestride, biasFalse, padding1)self.bn2 nn.BatchNorm2d(width)# -----------------------------------------self.conv3 nn.Conv2d(in_channelswidth, out_channelsout_channel*self.expansion,kernel_size1, stride1, biasFalse) # unsqueeze channelsself.bn3 nn.BatchNorm2d(out_channel*self.expansion)self.relu nn.ReLU(inplaceTrue)self.downsample downsampledef forward(self, x):identity xif self.downsample is not None:identity self.downsample(x)out self.conv1(x)out self.bn1(out)out self.relu(out)out self.conv2(out)out self.bn2(out)out self.relu(out)out self.conv3(out)out self.bn3(out)out identityout self.relu(out)return outclass ResNet(nn.Module):def __init__(self,block,blocks_num,num_classes1000,include_topTrue,groups1,width_per_group64):super(ResNet, self).__init__()self.include_top include_topself.in_channel 64self.groups groupsself.width_per_group width_per_groupself.conv1 nn.Conv2d(3, self.in_channel, kernel_size7, stride2,padding3, biasFalse)self.bn1 nn.BatchNorm2d(self.in_channel)self.relu nn.ReLU(inplaceTrue)self.maxpool nn.MaxPool2d(kernel_size3, stride2, padding1)self.layer1 self._make_layer(block, 64, blocks_num[0])self.layer2 self._make_layer(block, 128, blocks_num[1], stride2)self.layer3 self._make_layer(block, 256, blocks_num[2], stride2)self.layer4 self._make_layer(block, 512, blocks_num[3], stride2)if self.include_top:self.avgpool nn.AdaptiveAvgPool2d((1, 1)) # output size (1, 1)self.fc nn.Linear(512 * block.expansion, num_classes)for m in self.modules():if isinstance(m, nn.Conv2d):nn.init.kaiming_normal_(m.weight, modefan_out, nonlinearityrelu)def _make_layer(self, block, channel, block_num, stride1):downsample Noneif stride ! 1 or self.in_channel ! channel * block.expansion:downsample nn.Sequential(nn.Conv2d(self.in_channel, channel * block.expansion, kernel_size1, stridestride, biasFalse),nn.BatchNorm2d(channel * block.expansion))layers []layers.append(block(self.in_channel,channel,downsampledownsample,stridestride,groupsself.groups,width_per_groupself.width_per_group))self.in_channel channel * block.expansionfor _ in range(1, block_num):layers.append(block(self.in_channel,channel,groupsself.groups,width_per_groupself.width_per_group))return nn.Sequential(*layers)def forward(self, x):x self.conv1(x)x self.bn1(x)x self.relu(x)x self.maxpool(x)x self.layer1(x)x self.layer2(x)x self.layer3(x)x self.layer4(x)if self.include_top:x self.avgpool(x)x torch.flatten(x, 1)x self.fc(x)return xdef resnet34(num_classes1000, include_topTrue):# https://download.pytorch.org/models/resnet34-333f7ec4.pthreturn ResNet(BasicBlock, [3, 4, 6, 3], num_classesnum_classes, include_topinclude_top)def resnet50(num_classes1000, include_topTrue):# https://download.pytorch.org/models/resnet50-19c8e357.pthreturn ResNet(Bottleneck, [3, 4, 6, 3], num_classesnum_classes, include_topinclude_top)def resnet101(num_classes1000, include_topTrue):# https://download.pytorch.org/models/resnet101-5d3b4d8f.pthreturn ResNet(Bottleneck, [3, 4, 23, 3], num_classesnum_classes, include_topinclude_top)def resnext50_32x4d(num_classes1000, include_topTrue):# https://download.pytorch.org/models/resnext50_32x4d-7cdf4587.pthgroups 32width_per_group 4return ResNet(Bottleneck, [3, 4, 6, 3],num_classesnum_classes,include_topinclude_top,groupsgroups,width_per_groupwidth_per_group)def resnext101_32x8d(num_classes1000, include_topTrue):# https://download.pytorch.org/models/resnext101_32x8d-8ba56ff5.pthgroups 32width_per_group 8return ResNet(Bottleneck, [3, 4, 23, 3],num_classesnum_classes,include_topinclude_top,groupsgroups,width_per_groupwidth_per_group)
http://www.ho-use.cn/article/10812325.html

相关文章:

  • 怎样做医院网站南宁seo营销推广
  • 网站模板 瀑布流DW做的网页用网站打不开
  • 网站后台怎么建设2017国办网站建设规范
  • 网站建设包含的内容佛山公司网站推广外包服务
  • 深圳安嘉建设有限公司网站舞阳专业做网站
  • 质量好网站建设费用北京seo的排名优化
  • 深圳比邻网站建设深汕特别合作区房价最新消息
  • 万网空间上传网站吗免费创建单页网站
  • app展示网站模板html上海注销公司需要什么资料和流程
  • 分销系统网站建设建筑官方网站
  • 苏州安岭网站建设公司做网站后期需要什么费用
  • 上海模板建站源码建设网站运营收入
  • 吴江网站设计傻瓜式做网站哪个软件好
  • 沈阳网站建设公司怎么样wordpress 发表时间
  • 做网站外包公司有哪些wordpress修改模版
  • 佛山建设工程交易中心网站阿里 wordpress
  • 网站代码优化所有标签动图从哪个网站做
  • 专业邯郸做网站南昌网站推广
  • 衡阳做网站ss0734qq营销软件开发
  • 移动广告公司网站建设个人怎么做网页
  • 北京网站建设公司排行榜wordpress页脚添加联系qq
  • 免费做团购网站的软件有哪些注册公司费用计入什么科目
  • 电子商务营销方法网站怎么做才能得到更好的优化
  • 网站个性化制作wordpress修改界面
  • 怎么用手机制作手机网站软件技术和软件工程一样吗
  • 织梦 网站栏目管理便宜网站建设成都
  • 现在网站开发都什么技术余姚网站建设 熊掌号
  • c net做的网站无排名优化
  • 做移门配件的网站网站如何链接备案系统
  • 平面图网站浙江省建筑工程信息网