深度学习论文: NAM: Normalization | 您所在的位置:网站首页 › nam是哪里的姓 › 深度学习论文: NAM: Normalization |
深度学习论文: NAM: Normalization-based Attention Module及其PyTorch实现 NAM: Normalization-based Attention Module PDF: https://arxiv.org/pdf/2111.12419.pdf PyTorch代码: https://github.com/shanglianlm0525/CvPytorch PyTorch代码: https://github.com/shanglianlm0525/PyTorch-Networks 1 概述NAM作为一种高效、轻量级的注意力机制。 NAM采用CBAM的模块整合,重新设计了通道和空间注意力子模块。在每个网络块的末端嵌入一个NAM模块。对于残差网络,它嵌入在残差结构的末端。利用权重的贡献因子来改善注意力机制。使用批归一化的比例因子,它使用标准差来表示权重的重要性。这可以避免添加SE、BAM和CBAM中使用的全连接层和卷积层。 2 NAM 2-1 channel attention对于通道注意子模块,使用批归一化(BN)中的比例因子测量通道的方差并指出它们的重要性。 对于空间注意子模块,将BN的比例因子应用于空间维度,来衡量像素的重要性。称之为像素归一化。 PyTorch代码: import torch import torch.nn as nn class NAM(nn.Module): def __init__(self, channels, t=16): super(NAM, self).__init__() self.channels = channels self.bn2 = nn.BatchNorm2d(self.channels, affine=True) def forward(self, x): residual = x x = self.bn2(x) weight_bn = self.bn2.weight.data.abs() / torch.sum(self.bn2.weight.data.abs()) x = x.permute(0, 2, 3, 1).contiguous() x = torch.mul(weight_bn, x) x = x.permute(0, 3, 1, 2).contiguous() x = torch.sigmoid(x) * residual # return x 3 Experiment |
CopyRight 2018-2019 实验室设备网 版权所有 |