Concurrent Spatial and Channel Squeeze & Excitation in Fullly Convolutional Networks 代码复现

Miracle 2019年4月18日17:22:48干货教程 深度学习Concurrent Spatial and Channel Squeeze & Excitation in Fullly Convolutional Networks 代码复现已关闭评论2,11581297字阅读4分19秒阅读模式

三种SENet Pytorch代码如下:文章源自联网快讯-https://x1995.cn/4534.html

  1. class CSEModule(nn.Module):
  2.     def __init__(self, ch, re=16):
  3.         super().__init__()
  4.         self.cSE = nn.Sequential(nn.AdaptiveAvgPool2d(1),
  5.                                  nn.Conv2d(ch,ch//re,1),
  6.                                  nn.ReLU(inplace=True),
  7.                                  nn.Conv2d(ch//re,ch,1),
  8.                                  nn.Sigmoid())
  9.     def forward(self, x):
  10.         return x * self.cSE(x) #cSE
  11. class SSEModule(nn.Module):
  12.     def __init__(self, ch, re=16):
  13.         super().__init__()
  14.         self.sSE = nn.Sequential(nn.Conv2d(ch,ch,1),
  15.                                  nn.Sigmoid())
  16.     def forward(self, x):
  17.         return x * self.sSE(x)  #sSE
  18. class SCSEModule(nn.Module):
  19.     def __init__(self, ch, re=16):
  20.         super().__init__()
  21.         self.cSE = nn.Sequential(nn.AdaptiveAvgPool2d(1),
  22.                                  nn.Conv2d(ch,ch//re,1),
  23.                                  nn.ReLU(inplace=True),
  24.                                  nn.Conv2d(ch//re,ch,1),
  25.                                  nn.Sigmoid())
  26.         self.sSE = nn.Sequential(nn.Conv2d(ch,ch,1),
  27.                                  nn.Sigmoid())
  28.     def forward(self, x):
  29.         return x * self.cSE(x) + x * self.sSE(x)  #scSE

论文原文:Concurrent Spatial and Channel Squeeze & Excitation in Fullly Convolutional Networks文章源自联网快讯-https://x1995.cn/4534.html

继续阅读
Miracle
  • 本文由 发表于 2019年4月18日17:22:48