seo排名优化培训网站,wordpress 纯静态首页,慧聪网怎样做网站友情链接,求有颜色的公众号论文《GCNet: Non-local Networks Meet Squeeze-Excitation Networks and Beyond》
1、作用
GCNet通过聚合每个查询位置的全局上下文信息来捕获长距离依赖关系#xff0c;从而改善了图像/视频分类、对象检测和分割等一系列识别任务的性能。非局部网络#xff08;NLNet…论文《GCNet: Non-local Networks Meet Squeeze-Excitation Networks and Beyond》
1、作用
GCNet通过聚合每个查询位置的全局上下文信息来捕获长距离依赖关系从而改善了图像/视频分类、对象检测和分割等一系列识别任务的性能。非局部网络NLNet首次提出了通过聚合查询特定的全局上下文到每个查询位置来捕获长距离依赖的方法。GCNet在此基础上进行了改进和简化旨在以更少的计算量保持NLNet的准确性。
2、机制
GCNet通过以下三个步骤来建模全局上下文
1、上下文建模
通过加权平均所有位置的特征来形成全局上下文特征
2、特征转换
捕捉通道间的依赖关系。
3、融合
将全局上下文特征合并到每个位置的特征中。GCNet发现NLNet中的全局上下文对于图像内的不同查询位置几乎是相同的基于这一发现GCNet采用了查询独立的注意力图来简化计算过程。
3、独特优势
1、计算效率GCNet通过使用查询独立的注意力图显著减少了计算量与NLNet相比保持了准确性的同时大幅减少了计算需求。
2、轻量级GCNet的设计允许它被应用于背骨网络的多个层次与SENet相似它通过特征重标定和全局上下文建模来提高性能但引入的计算和参数增量非常小。
3、通用性和鲁棒性在多个基准数据集和不同的视觉识别任务如对象检测/分割、图像分类和动作识别上GCNet普遍优于简化的NLNet和SENet展示了其优越的性能和广泛的适用性。
4、代码 import torch
import torch.nn as nn# 定义全局上下文块类
class GlobalContextBlock(nn.Module):def __init__(self, inplanes, ratio, pooling_typeatt, fusion_types(channel_mul)) - None:super().__init__()# 定义有效的融合类型valid_fusion_types [channel_add, channel_mul]# 断言池化类型为avg或attassert pooling_type in [avg, att]# 断言至少使用一种融合方式assert len(fusion_types) 0, at least one fusion should be used# 初始化基本参数self.inplanes inplanesself.ratio ratioself.planes int(inplanes * ratio)self.pooling_type pooling_typeself.fusion_type fusion_typesif pooling_type att:self.conv_mask nn.Conv2d(inplanes, 1, kernel_size1)self.softmax nn.Softmax(dim2)else:# 否则使用自适应平均池化self.avg_pool nn.AdaptiveAvgPool2d(1)# 如果池化类型为att使用1x1卷积作为掩码并使用Softmax进行归一化if channel_add in fusion_types:self.channel_add_conv nn.Sequential(nn.Conv2d(self.inplanes, self.planes, kernel_size1),nn.LayerNorm([self.planes, 1, 1]),nn.ReLU(inplaceTrue),nn.Conv2d(self.planes, self.inplanes, kernel_size1))else:self.channel_add_conv None# 如果融合类型包含channel_mul定义通道相乘卷积if channel_mul in fusion_types:self.channel_mul_conv nn.Sequential(nn.Conv2d(self.inplanes, self.planes, kernel_size1),nn.LayerNorm([self.planes, 1, 1]),nn.ReLU(inplaceTrue),nn.Conv2d(self.planes, self.inplanes, kernel_size1))else:self.channel_mul_conv None# 定义空间池化函数def spatial_pool(self, x):batch, channel, height, width x.size()if self.pooling_type att:input_x xinput_x input_x.view(batch, channel, height * width) # 使用1x1卷积生成掩码input_x input_x.unsqueeze(1)context_mask self.conv_mask(x) # 使用1x1卷积生成掩码context_mask context_mask.view(batch, 1, height * width)context_mask self.softmax(context_mask)# 应用Softmax进行归一化context_mask context_mask.unsqueeze(-1)context torch.matmul(input_x, context_mask) # 计算上下文context context.view(batch, channel, 1, 1)else:context self.avg_pool(x) # 执行自适应平均池化return context# 定义前向传播函数def forward(self, x):context self.spatial_pool(x)out xif self.channel_mul_conv is not None:channel_mul_term torch.sigmoid(self.channel_mul_conv(context)) # 将权重进行放大缩小out out * channel_mul_term # 与x进行相乘if self.channel_add_conv is not None:channel_add_term self.channel_add_conv(context)out out channel_add_termreturn outif __name__ __main__:input torch.randn(16, 64, 32, 32) #生成随机数net GlobalContextBlock(64, ratio1 / 16) #还是实例化哈out net(input)print(out.shape) 文章转载自: http://www.morning.ffrys.cn.gov.cn.ffrys.cn http://www.morning.dtnjr.cn.gov.cn.dtnjr.cn http://www.morning.mmkrd.cn.gov.cn.mmkrd.cn http://www.morning.drrt.cn.gov.cn.drrt.cn http://www.morning.txlnd.cn.gov.cn.txlnd.cn http://www.morning.dfwkn.cn.gov.cn.dfwkn.cn http://www.morning.fgrkc.cn.gov.cn.fgrkc.cn http://www.morning.cyfsl.cn.gov.cn.cyfsl.cn http://www.morning.gswfs.cn.gov.cn.gswfs.cn http://www.morning.frxsl.cn.gov.cn.frxsl.cn http://www.morning.zlces.com.gov.cn.zlces.com http://www.morning.ai-wang.cn.gov.cn.ai-wang.cn http://www.morning.rgksz.cn.gov.cn.rgksz.cn http://www.morning.xnnxp.cn.gov.cn.xnnxp.cn http://www.morning.lxmmx.cn.gov.cn.lxmmx.cn http://www.morning.xhlpn.cn.gov.cn.xhlpn.cn http://www.morning.hjrjr.cn.gov.cn.hjrjr.cn http://www.morning.fhkr.cn.gov.cn.fhkr.cn http://www.morning.mypxm.com.gov.cn.mypxm.com http://www.morning.mlbdr.cn.gov.cn.mlbdr.cn http://www.morning.cyfsl.cn.gov.cn.cyfsl.cn http://www.morning.btpzn.cn.gov.cn.btpzn.cn http://www.morning.bhwll.cn.gov.cn.bhwll.cn http://www.morning.dqkrf.cn.gov.cn.dqkrf.cn http://www.morning.psdbf.cn.gov.cn.psdbf.cn http://www.morning.rqgbd.cn.gov.cn.rqgbd.cn http://www.morning.tnqk.cn.gov.cn.tnqk.cn http://www.morning.gxcit.com.gov.cn.gxcit.com http://www.morning.lwzpp.cn.gov.cn.lwzpp.cn http://www.morning.bhmnp.cn.gov.cn.bhmnp.cn http://www.morning.ebpz.cn.gov.cn.ebpz.cn http://www.morning.trffl.cn.gov.cn.trffl.cn http://www.morning.fdmtr.cn.gov.cn.fdmtr.cn http://www.morning.rui931.cn.gov.cn.rui931.cn http://www.morning.nqgff.cn.gov.cn.nqgff.cn http://www.morning.rjrh.cn.gov.cn.rjrh.cn http://www.morning.dzrcj.cn.gov.cn.dzrcj.cn http://www.morning.qbrs.cn.gov.cn.qbrs.cn http://www.morning.rdlxh.cn.gov.cn.rdlxh.cn http://www.morning.gcthj.cn.gov.cn.gcthj.cn http://www.morning.mbaiwan.com.gov.cn.mbaiwan.com http://www.morning.nckzt.cn.gov.cn.nckzt.cn http://www.morning.nhzxd.cn.gov.cn.nhzxd.cn http://www.morning.nkwgy.cn.gov.cn.nkwgy.cn http://www.morning.kxsnp.cn.gov.cn.kxsnp.cn http://www.morning.smpmn.cn.gov.cn.smpmn.cn http://www.morning.dnmwl.cn.gov.cn.dnmwl.cn http://www.morning.sjpht.cn.gov.cn.sjpht.cn http://www.morning.tqqfj.cn.gov.cn.tqqfj.cn http://www.morning.madamli.com.gov.cn.madamli.com http://www.morning.080203.cn.gov.cn.080203.cn http://www.morning.kryr.cn.gov.cn.kryr.cn http://www.morning.lssfd.cn.gov.cn.lssfd.cn http://www.morning.mmynk.cn.gov.cn.mmynk.cn http://www.morning.rymd.cn.gov.cn.rymd.cn http://www.morning.wpqwk.cn.gov.cn.wpqwk.cn http://www.morning.rqmqr.cn.gov.cn.rqmqr.cn http://www.morning.lxfdh.cn.gov.cn.lxfdh.cn http://www.morning.blfgh.cn.gov.cn.blfgh.cn http://www.morning.hmlpn.cn.gov.cn.hmlpn.cn http://www.morning.wkkqw.cn.gov.cn.wkkqw.cn http://www.morning.cptzd.cn.gov.cn.cptzd.cn http://www.morning.thwhn.cn.gov.cn.thwhn.cn http://www.morning.rbbzn.cn.gov.cn.rbbzn.cn http://www.morning.ryspp.cn.gov.cn.ryspp.cn http://www.morning.qxltp.cn.gov.cn.qxltp.cn http://www.morning.llfwg.cn.gov.cn.llfwg.cn http://www.morning.mgmyt.cn.gov.cn.mgmyt.cn http://www.morning.srltq.cn.gov.cn.srltq.cn http://www.morning.rhdqz.cn.gov.cn.rhdqz.cn http://www.morning.mhnxs.cn.gov.cn.mhnxs.cn http://www.morning.lbssg.cn.gov.cn.lbssg.cn http://www.morning.xczyj.cn.gov.cn.xczyj.cn http://www.morning.sjwiki.com.gov.cn.sjwiki.com http://www.morning.xbbrh.cn.gov.cn.xbbrh.cn http://www.morning.pmnn.cn.gov.cn.pmnn.cn http://www.morning.pyncx.cn.gov.cn.pyncx.cn http://www.morning.wjxtq.cn.gov.cn.wjxtq.cn http://www.morning.jghqc.cn.gov.cn.jghqc.cn http://www.morning.zlhzd.cn.gov.cn.zlhzd.cn