FcaNet: Frequency Channel Attention Networks
PDF: ​​​https://arxiv.org/pdf/2012.11879.pdf​​​ PyTorch代码: ​​https://github.com/shanglianlm0525/PyTorch-Networks​​ PyTorch代码: ​​https://github.com/shanglianlm0525/CvPytorch​

1 概述

  • 从频域角度分析通道注意力机制
  • 基于频域分析,GAP是频域特征分解的一种特例
  • 提出一种“two-step”准则选择频域成分
  • 注意力机制论文:FcaNet: Frequency Channel Attention Networks及其PyTorch实现_神经网络

2 Frequency Channel Attention

GAP可以视作输入的最低频信息,而在通道注意力中仅仅采用GAP是不够充分的。

“two-step”准则选择频域成分: 首先确定每个频率成分的重要性,然后确定不同数量频率成分的影响性。首先,独立的确认每个通道的不同频率成分的结果,然后选择Top-k高性能频率成分。

注意力机制论文:FcaNet: Frequency Channel Attention Networks及其PyTorch实现_神经网络_02


PyTorch代码:

class FCABlock(nn.Module):
"""
FcaNet: Frequency Channel Attention Networks
https://arxiv.org/pdf/2012.11879.pdf
"""
def __init__(self, channel, reduction=16, dct_weight=None):
super(FCABlock, self).__init__()
mid_channel = channel // reduction
self.dct_weight = dct_weight
self.excitation = nn.Sequential(
nn.Linear(channel, mid_channel, bias=False),
nn.ReLU(inplace=True),
nn.Linear(mid_channel, channel, bias=False),
nn.Sigmoid()
)

def forward(self, x):
b, c, _, _ = x.size()
y = torch.sum(x*self.dct_weight, dim=[2,3])
z = self.excitation(y).view(b, c, 1, 1)
return x * z.expand_as(x)

3 Experiments

注意力机制论文:FcaNet: Frequency Channel Attention Networks及其PyTorch实现_神经网络_03