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

Class SpatialAttentionModule

lib/Modules.py:222–233  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

220
221
222class SpatialAttentionModule(nn.Module):
223 def __init__(self):
224 super(SpatialAttentionModule, self).__init__()
225 self.conv2d = nn.Conv2d(in_channels=2, out_channels=1, kernel_size=7, stride=1, padding=3)
226 self.sigmoid = nn.Sigmoid()
227
228 def forward(self, x):
229 avgout = torch.mean(x, dim=1, keepdim=True)
230 maxout, _ = torch.max(x, dim=1, keepdim=True)
231 out = torch.cat([avgout, maxout], dim=1)
232 out = self.sigmoid(self.conv2d(out))
233 return out
234
235
236class CBAM(nn.Module):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected