MCPcopy Create free account
hub / github.com/ChunmingHe/WS-SAM / RCAB

Class RCAB

lib/Modules.py:685–707  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

683
684
685class RCAB(nn.Module):
686 # paper: Image Super-Resolution Using Very DeepResidual Channel Attention Networks
687 # input: B*C*H*W
688 # output: B*C*H*W
689 def __init__(self, n_feat, kernel_size=3, reduction=16, bias=True, bn=False, act=nn.ReLU(True), res_scale=1):
690
691 super(RCAB, self).__init__()
692 modules_body = []
693 for i in range(2):
694 modules_body.append(self.default_conv(n_feat, n_feat, kernel_size, bias=bias))
695 if bn: modules_body.append(nn.BatchNorm2d(n_feat))
696 if i == 0: modules_body.append(act)
697 modules_body.append(CALayer(n_feat, reduction))
698 self.body = nn.Sequential(*modules_body)
699 self.res_scale = res_scale
700
701 def default_conv(self, in_channels, out_channels, kernel_size, bias=True):
702 return nn.Conv2d(in_channels, out_channels, kernel_size, padding=(kernel_size // 2), bias=bias)
703
704 def forward(self, x):
705 res = self.body(x)
706 res += x
707 return res
708
709
710class Decoder4(nn.Module):

Callers 4

__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected