SENet 算法的介绍

一、总结

SENet 网络的创新点在于关注 channel 之间的关系,希望模型可以【自动学习到不同 channel 特征的重要程度】。为此,SENet 提出了 【Squeeze-and-Excitation(SE)】模块。

二、最后一届 ImageNet 冠军模型 SENet

1、SENet 基本介绍

SENet 是最后一届 ImageNet 2017 竞赛分类任务的冠军,top5 的错误率达到了 2.251%,比 2016 年的第一名还要低 25%,可谓提升巨大。

并且它本身的基础模块是轻量级的,非常容易扩展到其它的结构中去。

2、SENet 核心思想

SENet 网络的创新点在于关注 channel 之间的关系,希望模型可以自动学习到不同 channel 特征的重要程度。

为此,SENet 提出了 Squeeze-and-Excitation(SE)模块。

对于一张图片,不同的 channel 的权重一般都是不一样的。

如果,我们能够把这个信息捕获出来,那么我们的网络就可以获得更多的信息,那么自然就拥有更高得准确率。

3、SENet 中的 SE 模块

SE:Squeeze-and-Excitation

 

4、SE 模块在其它结构中的使用

在Inception中

 

在ResNet中

 

5、SENet 代码实现

参照

GitHub - moskomule/senet.pytorch: PyTorch implementation of SENet

https://github.com/moskomule/senet.pytorch

SE 模块是非常简单的,实现起来也比较容易,这里给出 PyTorch 版本的实现:

class SELayer(nn.Module):
    def __init__(self, channel, reduction=16):
        super(SELayer, self).__init__()
        self.avg_pool = nn.AdaptiveAvgPool2d(1)
        self.fc = nn.Sequential(
            nn.Linear(channel, channel // reduction, bias=False),
            nn.ReLU(inplace=True),
            nn.Linear(channel // reduction, channel, bias=False),
            nn.Sigmoid()
        )

    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)
        return x * y.expand_as(x)

对于 SE-ResNet 模型,只需要将 SE 模块加入到残差单元(应用在残差学习那一部分)就可以:

class SEBottleneck(nn.Module):
        expansion = 4

        def __init__(self, inplanes, planes, stride=1, downsample=None, reduction=16):
            super(SEBottleneck, self).__init__()
            self.conv1 = nn.Conv2d(inplanes, planes, kernel_size=1, bias=False)
            self.bn1 = nn.BatchNorm2d(planes)
            self.conv2 = nn.Conv2d(planes, planes, kernel_size=3, stride=stride,
                                   padding=1, bias=False)
            self.bn2 = nn.BatchNorm2d(planes)
            self.conv3 = nn.Conv2d(planes, planes * 4, kernel_size=1, bias=False)
            self.bn3 = nn.BatchNorm2d(planes * 4)
            self.relu = nn.ReLU(inplace=True)
            self.se = SELayer(planes * 4, reduction)
            self.downsample = downsample
            self.stride = stride

        def forward(self, x):
            residual = x

            out = self.conv1(x)
            out = self.bn1(out)
            out = self.relu(out)

            out = self.conv2(out)
            out = self.bn2(out)
            out = self.relu(out)

            out = self.conv3(out)
            out = self.bn3(out)
            out = self.se(out)

            if self.downsample is not None:
                residual = self.downsample(x)

            out += residual
            out = self.relu(out)

            return out

ResNet Block基本结构

 

6、继续学习

原论文

[1709.01507] Squeeze-and-Excitation Networks

https://arxiv.org/abs/1709.01507

代码实现

GitHub - moskomule/senet.pytorch: PyTorch implementation of SENet

https://github.com/moskomule/senet.pytorch

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值