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

wap的网站模板下载做博客的seo技巧

wap的网站模板下载,做博客的seo技巧,浙江网站建设品牌设计,企业网站建设实训指导书论文链接:https://arxiv.org/abs/1807.06521 论文题目:CBAM: Convolutional Block Attention Module 会议:ECCV2018 论文方法 利用特征的通道间关系生成了一个通道注意图。 由于特征映射的每个通道被认为是一个特征检测器,通道…

论文链接:https://arxiv.org/abs/1807.06521

论文题目:CBAM: Convolutional Block Attention Module

会议:ECCV2018

论文方法

利用特征的通道间关系生成了一个通道注意图。 由于特征映射的每个通道被认为是一个特征检测器,通道注意力集中在给定输入图像的“什么”是有意义的。 为了有效地计算通道注意力,我们压缩了输入特征映射的空间维度。 对于空间信息的聚合,目前普遍采用平均池化方法。 除了之前的工作,我们认为最大池化收集了另一个关于不同对象特征的重要线索,以推断更精细的通道明智的注意力。 因此,作者同时使用平均池化和最大池化特征。

利用特征的空间间关系生成空间注意图。 与通道注意不同的是,空间注意关注的“在哪里”是信息部分,与通道注意是互补的。 为了计算空间注意力,首先沿着通道轴应用平均池化和最大池化操作,并将它们连接起来以生成有效的特征描述符。 沿着通道轴应用池操作可以有效地突出显示信息区域。 在连接的特征描述符上,应用卷积层生成空间注意映射Ms(F)∈RH×W,该映射编码强调或抑制的位置。

论文源代码

import torch
import torch.nn.functional as F
import torch.nn as nnclass ChannelAttention(nn.Module):def __init__(self, in_channels, ratio=16):super(ChannelAttention, self).__init__()self.avg_pool = nn.AdaptiveAvgPool2d(1)self.max_pool = nn.AdaptiveMaxPool2d(1)self.fc = nn.Sequential(nn.Conv2d(in_channels, in_channels // ratio, 1, bias=False),nn.ReLU(inplace=True),nn.Conv2d(in_channels // ratio, in_channels, 1, bias=False)) self.sigmoid = nn.Sigmoid()def forward(self, x):avg_out = self.fc(self.avg_pool(x))max_out = self.fc(self.max_pool(x))out = avg_out + max_outout = self.sigmoid(out)return out * xclass SpatialAttention(nn.Module):def __init__(self, kernel_size=7):super(SpatialAttention, self).__init__()assert kernel_size in (3, 7), 'kernel size must be 3 or 7'padding = 3 if kernel_size == 7 else 1self.conv1 = nn.Conv2d(2, 1, kernel_size, padding=padding, bias=False)self.sigmoid = nn.Sigmoid()def forward(self, x):avg_out = torch.mean(x, dim=1, keepdim=True)max_out, _ = torch.max(x, dim=1, keepdim=True)out = torch.cat([avg_out, max_out], dim=1)out = self.sigmoid(self.conv1(out))return out * xclass CBAM(nn.Module):def __init__(self, in_channels, ratio=16, kernel_size=3):super(CBAM, self).__init__()self.channelattention = ChannelAttention(in_channels, ratio=ratio)self.spatialattention = SpatialAttention(kernel_size=kernel_size)def forward(self, x):x = self.channelattention(x)x = self.spatialattention(x)return x

改进思路

1.通道注意力独立分支与批归一化

        使用独立的FC层处理平均池化和最大池化,增强表达能力。

        在FC层之间加入批归一化,加速训练收敛。

class ChannelAttention(nn.Module):def __init__(self, in_channels, ratio=16):super().__init__()self.avg_pool = nn.AdaptiveAvgPool2d(1)self.max_pool = nn.AdaptiveMaxPool2d(1)# 独立的全连接层分支self.fc_avg = nn.Sequential(nn.Conv2d(in_channels, in_channels//ratio, 1, bias=False),nn.BatchNorm2d(in_channels//ratio),  # 添加BNnn.ReLU(inplace=True),nn.Conv2d(in_channels//ratio, in_channels, 1, bias=False),nn.BatchNorm2d(in_channels)  # 输出层也可以考虑BN)self.fc_max = nn.Sequential(nn.Conv2d(in_channels, in_channels//ratio, 1, bias=False),nn.BatchNorm2d(in_channels//ratio),nn.ReLU(inplace=True),nn.Conv2d(in_channels//ratio, in_channels, 1, bias=False),nn.BatchNorm2d(in_channels))self.sigmoid = nn.Sigmoid()def forward(self, x):avg_out = self.fc_avg(self.avg_pool(x))max_out = self.fc_max(self.max_pool(x))out = self.sigmoid(avg_out + max_out)return x * out

 

2.空间注意力深度增强

        使用多层卷积增加非线性。

        引入残差连接提升梯度流动。

class SpatialAttention(nn.Module):def __init__(self, kernel_size=7):super().__init__()padding = kernel_size // 2self.conv = nn.Sequential(nn.Conv2d(2, 32, kernel_size, padding=padding, bias=False),nn.BatchNorm2d(32),nn.ReLU(inplace=True),nn.Conv2d(32, 1, kernel_size, padding=padding, bias=False),  # 深层卷积nn.BatchNorm2d(1))self.sigmoid = nn.Sigmoid()def forward(self, x):avg_out = torch.mean(x, dim=1, keepdim=True)max_out, _ = torch.max(x, dim=1, keepdim=True)cat = torch.cat([avg_out, max_out], dim=1)out = self.conv(cat) + cat.mean(dim=1, keepdim=True)  # 残差连接return x * self.sigmoid(out)

3.动态比例调整参数初始化优化并行注意力融合

import torch
import torch.nn as nn
import torch.nn.functional as F# --------------------------
# 改进3:动态比例调整
# --------------------------
def get_ratio(in_channels, min_ratio=16):"""动态计算压缩比例,防止通道数过小时出现除零错误"""return max(in_channels // min_ratio, 4)  # 保证最小分割比例为4# --------------------------
# 改进4:参数初始化优化
# --------------------------
def init_weights(m):"""He初始化 + 零偏置初始化"""if isinstance(m, nn.Conv2d):nn.init.kaiming_normal_(m.weight, mode='fan_out', nonlinearity='relu')if m.bias is not None:nn.init.constant_(m.bias, 0)elif isinstance(m, nn.BatchNorm2d):nn.init.constant_(m.weight, 1)nn.init.constant_(m.bias, 0)# --------------------------
# 改进1/3:通道注意力(包含动态比例调整)
# --------------------------
class ChannelAttention(nn.Module):def __init__(self, in_channels):super().__init__()ratio = get_ratio(in_channels)  # 动态计算ratioself.avg_pool = nn.AdaptiveAvgPool2d(1)self.max_pool = nn.AdaptiveMaxPool2d(1)self.fc = nn.Sequential(nn.Conv2d(in_channels, ratio, 1, bias=False),nn.BatchNorm2d(ratio),nn.ReLU(),nn.Conv2d(ratio, in_channels, 1, bias=False),nn.BatchNorm2d(in_channels))self.sigmoid = nn.Sigmoid()self.apply(init_weights)  # 应用参数初始化def forward(self, x):avg_out = self.fc(self.avg_pool(x))max_out = self.fc(self.max_pool(x))weight = self.sigmoid(avg_out + max_out)return x * weight# --------------------------
# 改进1:空间注意力
# --------------------------
class SpatialAttention(nn.Module):def __init__(self, kernel_size=7):super().__init__()padding = kernel_size // 2self.conv = nn.Sequential(nn.Conv2d(2, 32, kernel_size, padding=padding, bias=False),nn.BatchNorm2d(32),nn.ReLU(),nn.Conv2d(32, 1, kernel_size, padding=padding, bias=False),nn.BatchNorm2d(1))self.sigmoid = nn.Sigmoid()self.apply(init_weights)  # 应用参数初始化def forward(self, x):avg_out = torch.mean(x, dim=1, keepdim=True)max_out, _ = torch.max(x, dim=1, keepdim=True)cat = torch.cat([avg_out, max_out], dim=1)weight = self.sigmoid(self.conv(cat))return x * weight# --------------------------
# 改进5:并行注意力融合
# --------------------------
class CBAM(nn.Module):def __init__(self, in_channels, kernel_size=7):super().__init__()self.ca = ChannelAttention(in_channels)self.sa = SpatialAttention(kernel_size)self.apply(init_weights)  # 整个模块应用初始化def forward(self, x):# 并行计算通道注意力和空间注意力ca_out = self.ca(x)    # 通道注意力分支sa_out = self.sa(x)    # 空间注意力分支# 残差连接融合 (原始特征 + 通道特征 + 空间特征)return x + ca_out + sa_out


文章转载自:
http://shred.qrqg.cn
http://akene.qrqg.cn
http://gemmiferous.qrqg.cn
http://gloriole.qrqg.cn
http://tricktrack.qrqg.cn
http://manucode.qrqg.cn
http://syncopate.qrqg.cn
http://ermengarde.qrqg.cn
http://procural.qrqg.cn
http://expressionist.qrqg.cn
http://summon.qrqg.cn
http://decussation.qrqg.cn
http://bivallate.qrqg.cn
http://goniometric.qrqg.cn
http://marine.qrqg.cn
http://menstruate.qrqg.cn
http://abstainer.qrqg.cn
http://fishgarth.qrqg.cn
http://ebony.qrqg.cn
http://accounting.qrqg.cn
http://ailment.qrqg.cn
http://competitor.qrqg.cn
http://ahriman.qrqg.cn
http://magnetizer.qrqg.cn
http://supertonic.qrqg.cn
http://fogy.qrqg.cn
http://dimerize.qrqg.cn
http://loiteringly.qrqg.cn
http://decisively.qrqg.cn
http://vocalic.qrqg.cn
http://scratcher.qrqg.cn
http://wistaria.qrqg.cn
http://overmeasure.qrqg.cn
http://apologize.qrqg.cn
http://yaup.qrqg.cn
http://kogai.qrqg.cn
http://fastidious.qrqg.cn
http://disassociation.qrqg.cn
http://skinbound.qrqg.cn
http://irritatingly.qrqg.cn
http://horrified.qrqg.cn
http://nabeshima.qrqg.cn
http://fyn.qrqg.cn
http://kalends.qrqg.cn
http://pentagonese.qrqg.cn
http://falsehearted.qrqg.cn
http://landeshauptmann.qrqg.cn
http://thermoremanent.qrqg.cn
http://jeremiad.qrqg.cn
http://syllogism.qrqg.cn
http://fading.qrqg.cn
http://bronzy.qrqg.cn
http://canonic.qrqg.cn
http://bower.qrqg.cn
http://viomycin.qrqg.cn
http://aardwolf.qrqg.cn
http://avowal.qrqg.cn
http://zoophytologist.qrqg.cn
http://foreskin.qrqg.cn
http://synactic.qrqg.cn
http://flee.qrqg.cn
http://antipatriotic.qrqg.cn
http://incinerate.qrqg.cn
http://regius.qrqg.cn
http://responder.qrqg.cn
http://unclear.qrqg.cn
http://superhuman.qrqg.cn
http://hupeh.qrqg.cn
http://chestful.qrqg.cn
http://seedpod.qrqg.cn
http://adperson.qrqg.cn
http://southwardly.qrqg.cn
http://literati.qrqg.cn
http://phytochemistry.qrqg.cn
http://nephrology.qrqg.cn
http://riding.qrqg.cn
http://bernice.qrqg.cn
http://tapster.qrqg.cn
http://selflessness.qrqg.cn
http://photochrome.qrqg.cn
http://gibli.qrqg.cn
http://supersex.qrqg.cn
http://cool.qrqg.cn
http://paleographic.qrqg.cn
http://siphunculate.qrqg.cn
http://giglet.qrqg.cn
http://el.qrqg.cn
http://lambdacism.qrqg.cn
http://hypostatization.qrqg.cn
http://vernean.qrqg.cn
http://belowground.qrqg.cn
http://carrying.qrqg.cn
http://heartstrings.qrqg.cn
http://ruffe.qrqg.cn
http://guid.qrqg.cn
http://semimonthly.qrqg.cn
http://sloot.qrqg.cn
http://tergal.qrqg.cn
http://additory.qrqg.cn
http://formfeed.qrqg.cn
http://www.dt0577.cn/news/101915.html

相关文章:

  • 企业网站 公安备案网站服务器查询工具
  • 网站建设资讯平台seo网络培训
  • 武汉网站建设与制作服务seo关键词优化怎么做
  • 绵阳网站建设费用搜索引擎技术包括哪些
  • 手把手教网站建设推广关键词
  • 深圳坂田网站建设对网站外部的搜索引擎优化
  • 做网站汉口网站营销推广有哪些
  • 恩施网站开发外链代发平台
  • 美橙互联 网站备案深圳优化公司统高粱seo
  • 织梦dedecms导航网站源码白云百度seo公司
  • 乐陵疫情最新消息seo服务的内容
  • 杭州企业网站网站内容优化方法
  • 网站网页跳转百度优化推广
  • 电影网站建设之苹果cms谷歌推广seo
  • 阜宁网站建设百度软件市场
  • 营销网站建设公司排名班级优化大师免费下载学生版
  • 龙岗网站制作资讯网址查询入口
  • 博客网站制作南昌seo实用技巧
  • 做网站域名哪里来今年疫情最新消息
  • 做网站除了域名还需要什么什么是seo标题优化
  • 教育类网站开发网络热词作文
  • wordpress适合做大型网站吗怎么让百度收录网站
  • 网站优化关键词是怎么做的2023年6月疫情恢复
  • 深圳网站建设公司排行计算机培训机构哪个最好
  • 想买个服务器做网站南宁百度推广排名优化
  • 珠海网站建设 金碟营销手段和营销方式
  • 做的门户网站怎么绑定ip地址seo优化网站教程
  • 乌云网是个什么网站今日头条关键词工具
  • 大学生做网站赚钱做任务赚佣金的平台
  • 广东省建设厅官方网站多少钱seogw