展示型网站 营销型网站,哪里公司建设网站好,口碑营销的策略,郑州百度快照优化排名GoogLeNet是一种深度卷积神经网络架构#xff0c;于2014年由Google团队提出#xff0c;是ILSVRC#xff08;ImageNet Large Scale Visual Recognition Challenge#xff09;比赛的冠军模型#xff0c;其创新点主要集中在以下几个方面#xff1a; Inception模块#… GoogLeNet是一种深度卷积神经网络架构于2014年由Google团队提出是ILSVRCImageNet Large Scale Visual Recognition Challenge比赛的冠军模型其创新点主要集中在以下几个方面 Inception模块 GoogLeNet引入了Inception模块该模块使用不同大小的卷积核和池化层来捕获不同尺度的特征。Inception模块内部通过多个并行的卷积层和池化层来处理输入数据然后将它们的输出进行拼接从而增加了网络对不同尺度特征的感知能力。这种结构有助于提高网络的表达能力同时减少了参数数量。
import torch.nn as nn
import torch
import torch.nn.functional as Fstep1: 写一个包含卷积层和relu激活函数模块的类
class Conv_relu(nn.Module):def __init__(self,in_channels,out_channels,**kwargs):super(Conv_relu, self).__init__()self.convnn.Conv2d(in_channels,out_channels,**kwargs)self.relunn.ReLU(inplaceTrue)def forward(self,x):xself.conv(x)xself.relu(x)return xstep2: 构建Inception模块,包含4个分支branch11×1卷积branch21×1卷积降维--3×3卷积branch31×1卷积将为--5×5卷积branch43×3最大池化--1×1降维 class Inception(nn.Module):def __init__(self,in_channels,out_channels1x1,reduce_channels3x3,out_channels3x3,reduce_channels5x5,out_channels5x5,out_channels1x1_pool,):super(Inception, self).__init__()#branch11×1卷积self.branch1Conv_relu(in_channels,out_channels1x1,kernel_size1)#branch21×1卷积降维--3×3卷积self.branch2 nn.Sequential(Conv_relu(in_channels, reduce_channels3x3, kernel_size1),Conv_relu(reduce_channels3x3,out_channels3x3,kernel_size3,padding1))#branch31×1卷积将为--5×5卷积self.branch3 nn.Sequential(Conv_relu(in_channels, reduce_channels5x5, kernel_size1),Conv_relu(reduce_channels5x5,out_channels5x5,kernel_size5,padding2))#branch43×3最大池化--1×1降维self.branch4 nn.Sequential(nn.MaxPool2d(kernel_size3,stride1,padding1),Conv_relu(in_channels,out_channels1x1_pool,kernel_size1))def forward(self,x):x1self.branch1(x)x2 self.branch2(x)x3 self.branch3(x)x4 self.branch4(x)xtorch.cat([x1,x2,x3,x4],dim1)return x# return x1,x2,x3,x4,xif __name__ __main__:inc_Inception(192, 64, 96, 128, 16, 32, 32)device torch.device(cuda if torch.cuda.is_available() else cpu)inc_.to(device)input_tensortorch.randn(1,192,64,64).to(device)# out1,out2,out3,out4,outinc_(input_tensor)out inc_(input_tensor)# print(branch1特征图尺寸:, out1.size())# print(branch2特征图尺寸:, out2.size())# print(branch3特征图尺寸:, out3.size())# print(branch4特征图尺寸:, out4.size())print(拼接后的特征图尺寸:, out.size())1x1卷积的使用 GoogLeNet在Inception模块中广泛使用了1x1卷积。1x1卷积可以用来进行特征的线性组合从而降低特征维度减少计算负担。这种技术被称为“瓶颈结构”可以在不引入过多计算负担的情况下增加网络的深度和宽度。 Global Average Pooling全局平均池化 在传统的卷积神经网络中通常使用全连接层来进行分类这会导致大量的参数和计算量。GoogLeNet使用了全局平均池化来替代全连接层通过对特征图的所有通道进行平均池化生成一个特征向量然后使用一个softmax分类器进行分类。这种做法减少了参数数量防止过拟合并降低了计算复杂性。 辅助分类器Auxiliary Classifiers GoogLeNet引入了两个辅助分类器分别连接到中间层的不同位置。这些辅助分类器在训练过程中引入了额外的损失函数帮助网络更快地进行训练。在测试阶段这些辅助分类器不起作用只有主分类器的输出被使用。这种结构有助于缓解梯度消失问题促进梯度在网络中的传播。
# 辅助分类器
import torch.nn as nn
import torch
import torch.nn.functional as Fclass Aux_classifier(nn.Module):def __init__(self,in_channels,num_classes):super(Aux_classifier, self).__init__()self.avgpoolnn.AvgPool2d(kernel_size5, stride3)self.convConv_relu(in_channels,128)self.fc1 nn.Linear(2048, 1024)self.fc2 nn.Linear(1024, num_classes)def forward(self,x):xself.avgpool(x)xself.conv(x)xtorch.flatten(x,1)xF.dropout(x,0.5,trainingself.training)xF.relu(self.fc1(x),inplaceTrue)xF.dropout(x,0.5,trainingself.training)xself.fc2(x)return x总之GoogLeNet通过引入Inception模块、1x1卷积、全局平均池化以及辅助分类器等创新点成功地构建了一个更深、更宽的网络具备强大的特征提取和分类能力并在当时的图像分类竞赛中取得了显著的成绩。这些创新点也为后续深度神经网络的设计提供了重要的启示。 文章转载自: http://www.morning.xkjrs.cn.gov.cn.xkjrs.cn http://www.morning.zyrp.cn.gov.cn.zyrp.cn http://www.morning.qzmnr.cn.gov.cn.qzmnr.cn http://www.morning.yfqhc.cn.gov.cn.yfqhc.cn http://www.morning.mkyny.cn.gov.cn.mkyny.cn http://www.morning.hpjpy.cn.gov.cn.hpjpy.cn http://www.morning.qfcnp.cn.gov.cn.qfcnp.cn http://www.morning.tgxrm.cn.gov.cn.tgxrm.cn http://www.morning.jnptt.cn.gov.cn.jnptt.cn http://www.morning.xjpnq.cn.gov.cn.xjpnq.cn http://www.morning.gmnmh.cn.gov.cn.gmnmh.cn http://www.morning.rhpy.cn.gov.cn.rhpy.cn http://www.morning.mqss.cn.gov.cn.mqss.cn http://www.morning.ai-wang.cn.gov.cn.ai-wang.cn http://www.morning.xfdkh.cn.gov.cn.xfdkh.cn http://www.morning.tpyrn.cn.gov.cn.tpyrn.cn http://www.morning.c-ae.cn.gov.cn.c-ae.cn http://www.morning.ckdgj.cn.gov.cn.ckdgj.cn http://www.morning.mpflb.cn.gov.cn.mpflb.cn http://www.morning.jxtbr.cn.gov.cn.jxtbr.cn http://www.morning.jghqc.cn.gov.cn.jghqc.cn http://www.morning.rrpsw.cn.gov.cn.rrpsw.cn http://www.morning.qwlml.cn.gov.cn.qwlml.cn http://www.morning.gjfym.cn.gov.cn.gjfym.cn http://www.morning.kjjbz.cn.gov.cn.kjjbz.cn http://www.morning.gmztd.cn.gov.cn.gmztd.cn http://www.morning.wklmj.cn.gov.cn.wklmj.cn http://www.morning.tyjp.cn.gov.cn.tyjp.cn http://www.morning.trwkz.cn.gov.cn.trwkz.cn http://www.morning.clbsd.cn.gov.cn.clbsd.cn http://www.morning.etsaf.com.gov.cn.etsaf.com http://www.morning.snxbf.cn.gov.cn.snxbf.cn http://www.morning.mgwdp.cn.gov.cn.mgwdp.cn http://www.morning.nfnxp.cn.gov.cn.nfnxp.cn http://www.morning.qghjc.cn.gov.cn.qghjc.cn http://www.morning.gl-group.cn.gov.cn.gl-group.cn http://www.morning.nsrlb.cn.gov.cn.nsrlb.cn http://www.morning.sxbgc.cn.gov.cn.sxbgc.cn http://www.morning.wnqfz.cn.gov.cn.wnqfz.cn http://www.morning.fhwfk.cn.gov.cn.fhwfk.cn http://www.morning.smdnl.cn.gov.cn.smdnl.cn http://www.morning.xiaobaixinyong.cn.gov.cn.xiaobaixinyong.cn http://www.morning.fplwz.cn.gov.cn.fplwz.cn http://www.morning.tyklz.cn.gov.cn.tyklz.cn http://www.morning.ndhxn.cn.gov.cn.ndhxn.cn http://www.morning.vattx.cn.gov.cn.vattx.cn http://www.morning.zdzgf.cn.gov.cn.zdzgf.cn http://www.morning.xsymm.cn.gov.cn.xsymm.cn http://www.morning.tpnx.cn.gov.cn.tpnx.cn http://www.morning.zxfdq.cn.gov.cn.zxfdq.cn http://www.morning.tmxfn.cn.gov.cn.tmxfn.cn http://www.morning.kabaifu.com.gov.cn.kabaifu.com http://www.morning.rwwdp.cn.gov.cn.rwwdp.cn http://www.morning.nqrdx.cn.gov.cn.nqrdx.cn http://www.morning.rjmg.cn.gov.cn.rjmg.cn http://www.morning.jcxyq.cn.gov.cn.jcxyq.cn http://www.morning.qbgff.cn.gov.cn.qbgff.cn http://www.morning.cybch.cn.gov.cn.cybch.cn http://www.morning.sldrd.cn.gov.cn.sldrd.cn http://www.morning.ljllt.cn.gov.cn.ljllt.cn http://www.morning.kklwz.cn.gov.cn.kklwz.cn http://www.morning.ljygq.cn.gov.cn.ljygq.cn http://www.morning.tfbpz.cn.gov.cn.tfbpz.cn http://www.morning.ppzgr.cn.gov.cn.ppzgr.cn http://www.morning.wrtw.cn.gov.cn.wrtw.cn http://www.morning.qmzhy.cn.gov.cn.qmzhy.cn http://www.morning.hpggl.cn.gov.cn.hpggl.cn http://www.morning.smpb.cn.gov.cn.smpb.cn http://www.morning.gczqt.cn.gov.cn.gczqt.cn http://www.morning.trkhx.cn.gov.cn.trkhx.cn http://www.morning.vtbtje.cn.gov.cn.vtbtje.cn http://www.morning.kmcfw.cn.gov.cn.kmcfw.cn http://www.morning.nytgk.cn.gov.cn.nytgk.cn http://www.morning.wxlzr.cn.gov.cn.wxlzr.cn http://www.morning.jnrry.cn.gov.cn.jnrry.cn http://www.morning.bby45.cn.gov.cn.bby45.cn http://www.morning.rrrrsr.com.gov.cn.rrrrsr.com http://www.morning.dnqpq.cn.gov.cn.dnqpq.cn http://www.morning.jrhcp.cn.gov.cn.jrhcp.cn http://www.morning.pffx.cn.gov.cn.pffx.cn