当前位置:   article > 正文

SENet 算法的介绍_senet算法

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 版本的实现:

  1. class SELayer(nn.Module):
  2. def __init__(self, channel, reduction=16):
  3. super(SELayer, self).__init__()
  4. self.avg_pool = nn.AdaptiveAvgPool2d(1)
  5. self.fc = nn.Sequential(
  6. nn.Linear(channel, channel // reduction, bias=False),
  7. nn.ReLU(inplace=True),
  8. nn.Linear(channel // reduction, channel, bias=False),
  9. nn.Sigmoid()
  10. )
  11. def forward(self, x):
  12. b, c, _, _ = x.size()
  13. y = self.avg_pool(x).view(b, c)
  14. y = self.fc(y).view(b, c, 1, 1)
  15. return x * y.expand_as(x)

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

  1. class SEBottleneck(nn.Module):
  2. expansion = 4
  3. def __init__(self, inplanes, planes, stride=1, downsample=None, reduction=16):
  4. super(SEBottleneck, self).__init__()
  5. self.conv1 = nn.Conv2d(inplanes, planes, kernel_size=1, bias=False)
  6. self.bn1 = nn.BatchNorm2d(planes)
  7. self.conv2 = nn.Conv2d(planes, planes, kernel_size=3, stride=stride,
  8. padding=1, bias=False)
  9. self.bn2 = nn.BatchNorm2d(planes)
  10. self.conv3 = nn.Conv2d(planes, planes * 4, kernel_size=1, bias=False)
  11. self.bn3 = nn.BatchNorm2d(planes * 4)
  12. self.relu = nn.ReLU(inplace=True)
  13. self.se = SELayer(planes * 4, reduction)
  14. self.downsample = downsample
  15. self.stride = stride
  16. def forward(self, x):
  17. residual = x
  18. out = self.conv1(x)
  19. out = self.bn1(out)
  20. out = self.relu(out)
  21. out = self.conv2(out)
  22. out = self.bn2(out)
  23. out = self.relu(out)
  24. out = self.conv3(out)
  25. out = self.bn3(out)
  26. out = self.se(out)
  27. if self.downsample is not None:
  28. residual = self.downsample(x)
  29. out += residual
  30. out = self.relu(out)
  31. 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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/290852
推荐阅读
  

闽ICP备14008679号