MCPcopy Create free account
hub / github.com/deepbrainai-research/float / SEBottleneck

Class SEBottleneck

models/__init__.py:237–278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

235
236
237class SEBottleneck(nn.Module):
238 expansion = 4
239
240 def __init__(self, inplanes, planes, stride=1, downsample=None, groups=1,
241 base_width=64, dilation=1, norm_layer=None,
242 *, reduction=16):
243 super(SEBottleneck, self).__init__()
244 if norm_layer is None:
245 norm_layer= nn.BatchNorm2d
246 self.conv1 = nn.Conv2d(inplanes, planes, kernel_size=1, bias=False)
247 self.bn1 = norm_layer(planes)
248 self.conv2 = nn.Conv2d(planes, planes, kernel_size=3, stride=stride, padding=1, bias=False)
249 self.bn2 = norm_layer(planes)
250 self.conv3 = nn.Conv2d(planes, planes * 4, kernel_size=1, bias=False)
251 self.bn3 = norm_layer(planes * 4)
252 self.relu = nn.ReLU(inplace=True)
253 self.se = SELayer(planes * 4, reduction)
254 self.downsample = downsample
255 self.stride = stride
256
257 def forward(self, x):
258 residual = x
259
260 out = self.conv1(x)
261 out = self.bn1(out)
262 out = self.relu(out)
263
264 out = self.conv2(out)
265 out = self.bn2(out)
266 out = self.relu(out)
267
268 out = self.conv3(out)
269 out = self.bn3(out)
270 out = self.se(out)
271
272 if self.downsample is not None:
273 residual = self.downsample(x)
274
275 out += residual
276 out = self.relu(out)
277
278 return out
279
280
281class ResNet(nn.Module):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected