先做平均池化,再做线性分类,再relu,再线性分类
我的理解是增强分类的。
下面是torch代码:
class SELayer(nn.Module):
def __init__(self, channel, reduction=4):
super(SELayer, self).__init__()
self.avg_pool = nn.AdaptiveAvgPool2d(1)
self.fc = nn.Sequential(
nn.Linear(channel, channel // reduction),
nn.ReLU(inplace=True),
nn.Linear(channel // reduction, channel), )
def forward(self, x):
b, c, _, _ = x.size()
y = self.avg_pool(x).view(b, c)
y = self.fc(y).view(b, c, 1, 1)
y = torch.clamp(y, 0, 1)
return x * y
我在m_v2 做分类,后面跟了一个selayer,收敛变得奇慢无比。
但是检测任务,好像能加快收敛,pelee能提升训练速度和精度
Code: https://github.com/megvii-model/WeightNet