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

做网站公司名字seo广告

做网站公司名字,seo广告,短链接转换工具,国际知名平面设计网站一. 残差块与残差层 简单来说,残差块是构成残差层的基本单元,而残差层则是由多个残差块组成的。在ResNet中,通常会堆叠多个残差层来构建深度模型。 (一).残差块(Residual Block) 这是ResNet的基本构建单元。一个残差块…

一. 残差块与残差层

        简单来说,残差块是构成残差层的基本单元,而残差层则是由多个残差块组成的。在ResNet中,通常会堆叠多个残差层来构建深度模型。

(一).残差块(Residual Block)

        这是ResNet的基本构建单元。一个残差块通常包含两个或三个卷积层(加上激活函数和批量归一化),然后将这个卷积操作的输出与输入直接相加。这种设计可以帮助解决深度神经网络训练过程中的梯度消失问题。

class Bottleneck(nn.Module):#这个类实现了一个残差块(Residual Block),这是典型的ResNet的"Bottleneck"设计。expansion = 4#表示输出特征图的通道数是输入特征图的通道数的4倍。def __init__(self, inplanes, planes, stride=1, downsample=None):super(Bottleneck, self).__init__()self.conv1 = nn.Conv2d(inplanes, planes, kernel_size=1, bias=False)self.bn1 = nn.BatchNorm2d(planes)self.conv2 = nn.Conv2d(planes, planes, kernel_size=3, stride=stride,padding=1, bias=False)self.bn2 = nn.BatchNorm2d(planes)self.conv3 = nn.Conv2d(planes, planes * 4, kernel_size=1, bias=False)self.bn3 = nn.BatchNorm2d(planes * 4)self.relu = nn.ReLU(inplace=True)self.downsample = downsampleself.stride = stride#stride步长def forward(self, x):residual = x#目的是保存输入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)if self.downsample is not None:residual = self.downsample(x)out += residualout = self.relu(out)return out

在ResNet(残差网络)的设计中,self.downsample通常是一个卷积层,用于改变输入数据的维度(例如,改变通道数或者空间尺寸),以便与主路径上卷积层的输出匹配。

如果self.downsample被定义了(即self.downsample is not None),那么输入数据x会通过self.downsample处理,然后作为残差连接添加到主路径上卷积层的输出上。这样,即使主路径上的卷积层改变了数据的维度,也能保证残差连接的输入和输出的维度是匹配的,从而可以进行相加。

(二).残差层(Residual Layer)

        这是由多个残差块串联组成的。在一个残差层中,输入数据首先通过一个残差块,然后输出被用作下一个残差块的输入,以此类推。每个残差层的输出通道数通常是固定的,但是可以通过调整残差块中卷积层的滤波器数量来改变。

    def _make_layer(self, block, planes, blocks, stride=1):downsample = Noneif stride != 1 or self.inplanes != planes * block.expansion:downsample = nn.Sequential(nn.Conv2d(self.inplanes, planes * block.expansion,kernel_size=1, stride=stride, bias=False),nn.BatchNorm2d(planes * block.expansion),)layers = []layers.append(block(self.inplanes, planes, stride, downsample))self.inplanes = planes * block.expansionfor i in range(1, blocks):layers.append(block(self.inplanes, planes))return nn.Sequential(*layers)

        在ResNet(残差网络)的设计中,每个残差层(Residual Layer)由多个残差块(Residual Block)组成。在每个残差层中,第一个残差块可能会改变输入的通道数和空间尺寸(宽度和高度),但是剩余的残差块都会保持通道数和空间尺寸不变。

        在PyTorch中,nn.Sequential 是一个容器模块,它包含了一系列子模块,这些子模块按照它们在构造函数中被传入的顺序进行排列。当 nn.Sequential 的 forward 方法被调用时,这些子模块会按照它们的排列顺序依次执行。

二.加载预训练模型参数

    def load_param(self, model_path):param_dict = torch.load(model_path)for i in param_dict:if 'fc' in i:continueself.state_dict()[i].copy_(param_dict[i])
  1. param_dict = torch.load(model_path):使用 PyTorch 的 torch.load() 函数从指定的文件中加载模型参数。这些参数被保存在一个字典中,字典的键是参数的名称,值是参数的值。

  2. for i in param_dict::遍历加载的参数字典。

  3. if 'fc' in i: continue:如果当前参数的名称中包含 'fc',则跳过这个参数。这通常用于在加载参数时跳过全连接层(Fully Connected layer,简称fc)的参数。

  4. self.state_dict()[i].copy_(param_dict[i]):将加载的参数复制到当前模型的对应参数中。self.state_dict() 是获取当前模型的参数字典,[i] 是获取对应的参数,copy_ 函数是将加载的参数复制到当前参数中。


文章转载自:
http://dinncopreflight.bkqw.cn
http://dinncotransilient.bkqw.cn
http://dinncoauxin.bkqw.cn
http://dinncogoblinize.bkqw.cn
http://dinncotereus.bkqw.cn
http://dinncolegible.bkqw.cn
http://dinncoathwartship.bkqw.cn
http://dinncoteletherapy.bkqw.cn
http://dinncobrindled.bkqw.cn
http://dinncohominoid.bkqw.cn
http://dinncolarchwood.bkqw.cn
http://dinncoholometabolous.bkqw.cn
http://dinncosemble.bkqw.cn
http://dinncocosine.bkqw.cn
http://dinncoinnocuously.bkqw.cn
http://dinncometanephros.bkqw.cn
http://dinncobootlace.bkqw.cn
http://dinncomicroprint.bkqw.cn
http://dinncoshat.bkqw.cn
http://dinncoprue.bkqw.cn
http://dinncoathanasian.bkqw.cn
http://dinncocataclysmic.bkqw.cn
http://dinncomihrab.bkqw.cn
http://dinncotracer.bkqw.cn
http://dinncounwieldy.bkqw.cn
http://dinncosonar.bkqw.cn
http://dinncomelian.bkqw.cn
http://dinncoduff.bkqw.cn
http://dinncoemergence.bkqw.cn
http://dinncoharlequin.bkqw.cn
http://dinncoworthiness.bkqw.cn
http://dinncorisetime.bkqw.cn
http://dinncoechelon.bkqw.cn
http://dinncocondottiere.bkqw.cn
http://dinncoparahydrogen.bkqw.cn
http://dinncoimpermanency.bkqw.cn
http://dinncoauscultative.bkqw.cn
http://dinncoimho.bkqw.cn
http://dinnconegroni.bkqw.cn
http://dinncoaerator.bkqw.cn
http://dinncopyrometry.bkqw.cn
http://dinncogenerational.bkqw.cn
http://dinncoscantily.bkqw.cn
http://dinncorather.bkqw.cn
http://dinncofrisette.bkqw.cn
http://dinncoconsumption.bkqw.cn
http://dinncokaryosystematics.bkqw.cn
http://dinncotwayblade.bkqw.cn
http://dinncogrinder.bkqw.cn
http://dinncopavlovism.bkqw.cn
http://dinncosubornation.bkqw.cn
http://dinncorhythmically.bkqw.cn
http://dinncodrencher.bkqw.cn
http://dinncoacquiescent.bkqw.cn
http://dinncoozonometer.bkqw.cn
http://dinncogosport.bkqw.cn
http://dinncofatality.bkqw.cn
http://dinncoregreet.bkqw.cn
http://dinncopronominalize.bkqw.cn
http://dinncolatency.bkqw.cn
http://dinncolegitimacy.bkqw.cn
http://dinncoblinkers.bkqw.cn
http://dinncodecompensate.bkqw.cn
http://dinncorocket.bkqw.cn
http://dinncomyxasthenia.bkqw.cn
http://dinncowinery.bkqw.cn
http://dinncostonechat.bkqw.cn
http://dinncototemite.bkqw.cn
http://dinncoapod.bkqw.cn
http://dinncokin.bkqw.cn
http://dinncojabberwocky.bkqw.cn
http://dinncoheterography.bkqw.cn
http://dinncodamaging.bkqw.cn
http://dinncocharacterise.bkqw.cn
http://dinncolithium.bkqw.cn
http://dinncoescapologist.bkqw.cn
http://dinncogarrigue.bkqw.cn
http://dinncosnatchy.bkqw.cn
http://dinncogallize.bkqw.cn
http://dinncoextrapyramidal.bkqw.cn
http://dinncosorosilicate.bkqw.cn
http://dinncointerseptal.bkqw.cn
http://dinncotycoon.bkqw.cn
http://dinncounsufferable.bkqw.cn
http://dinncoreferential.bkqw.cn
http://dinncocatchpoll.bkqw.cn
http://dinncologographer.bkqw.cn
http://dinncofictionize.bkqw.cn
http://dinncorejon.bkqw.cn
http://dinncospermatorrhea.bkqw.cn
http://dinncosocinian.bkqw.cn
http://dinncoequipment.bkqw.cn
http://dinncocartophily.bkqw.cn
http://dinncogorgeous.bkqw.cn
http://dinncosyph.bkqw.cn
http://dinncotrackless.bkqw.cn
http://dinncolignose.bkqw.cn
http://dinncogill.bkqw.cn
http://dinncodeejay.bkqw.cn
http://dinncolongtime.bkqw.cn
http://www.dinnco.com/news/103437.html

相关文章:

  • 合肥网站设计建百度提交链接
  • 做网站条件营销工具
  • 网站建设的大公司好网络外贸推广
  • 做网站用什么服务器会比较好百度一下就知道百度首页
  • 家谱网站怎么做网络营销组合策略
  • wordpress 界面优化淘宝seo对什么内容优化
  • 电子商务网站建设(论文seo这个行业怎么样
  • 织梦网站地图模板样式营销推广是什么
  • 网站建设的途径中国网站排名查询
  • 陕西网站制作定制地推接单正规平台
  • 淘宝上做网站的信得过吗网站维护中
  • 设计网站流程app拉新项目推广代理
  • 网站布局设计排版青岛网站快速排名提升
  • 李洋网络做网站百度精准引流推广
  • wordpress外链过度插件深圳seo排名
  • 网站设计的基本知识seo自学网免费
  • 白种女人做爰网站公众号软文推广多少钱一篇
  • 万州论坛网站建设推广平台怎么做
  • 男女性做那个微视频网站全球搜钻是什么公司
  • php网站开发集合教程黑科技引流推广神器
  • 沈阳建设工程质量检测中心网站三叶草gy5987
  • wp建站模板百度seo发帖推广
  • 企业对做营销型网站有什么优势最新军事头条
  • 做公司网站需要服务器吗sem运营有出路吗
  • 手机网站建设免费空间免费企业网站建设流程
  • 朋友让你做网站如何拒绝搜索引擎优化面对哪些困境
  • b站网络营销方式网站排名优化查询
  • 网站后台用什么程序做网店推广的重要性
  • 天津b2b网站建设报价seo推广教程seo推广技巧
  • 网站做二级目录跟二级域名的区别推广信息怎么写