![8ba58f00d696d3e30656e937d0fbb23b.png](https://img-blog.csdnimg.cn/img_convert/8ba58f00d696d3e30656e937d0fbb23b.png)
一、Address
![46121ef83b492ade42c409240a7da479.png](https://img-blog.csdnimg.cn/img_convert/46121ef83b492ade42c409240a7da479.png)
地址:http://arxiv.org/abs/2007.04417
二、Model
2.1 CBAM
这个是ECCV2018提出的,我想大家对这个都很熟悉了 这里简单提一下
paper 地址:https://openaccess.thecvf.com/content_ECCV_2018/papers/Sanghyun_Woo_Convolutional_Block_Attention_ECCV_2018_paper.pdf
![ded7959e4140b1eb11b016c7987be142.png](https://img-blog.csdnimg.cn/img_convert/ded7959e4140b1eb11b016c7987be142.png)
主要包括一个channel attention 一个spatial attention
这两个是cv领域的attention,其实看一下示意图就知道大概的代码怎么写了, 可以看下这两个之后 再看下代码就清楚了
class CBAM(nn.Module):
def __init__(self, input_channels, reduction_ratio=16, kernel_size=7):
super(CBAM, self).__init__()
self.channel_att = ChannelAttention(input_channels, reduction_ratio=reduction_ratio)
self.spatial_att = SpatialAttention(kernel_size=kernel_size)
def forward(self, x):
out = self.channel_att(x)
out = self.spatial_att(out)
return out
2.1.1 channel attention
![7c768c2fff71747e6ef43d600d7ab4bd.png](https://img-blog.csdnimg.cn/img_convert/7c768c2fff71747e6ef43d600d7ab4bd.png)
‘
将输入的feature map,分别经过基于宽高的global max pooling和global average pooling,然后分别经过MLP输出的特征进行基于element wise的加和操作,再经过sigmoid,生成最终的channel attention feature map,得到最终的channel attention,再将该channel attention feature ma