MCPcopy Create free account
hub / github.com/AtlasAnalyticsLab/AdaFisher / Bottleneck

Class Bottleneck

Image_Classification/src/models/resnet_cifar.py:43–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41
42
43class Bottleneck(nn.Module):
44 expansion = 4
45
46 def __init__(self, in_planes, planes, stride=1):
47 super(Bottleneck, self).__init__()
48 self.conv1 = nn.Conv2d(in_planes, planes, kernel_size=1, bias=False)
49 self.bn1 = nn.BatchNorm2d(planes)
50 self.conv2 = nn.Conv2d(planes, planes, kernel_size=3,
51 stride=stride, padding=1, bias=False)
52 self.bn2 = nn.BatchNorm2d(planes)
53 self.conv3 = nn.Conv2d(planes, self.expansion *
54 planes, kernel_size=1, bias=False)
55 self.bn3 = nn.BatchNorm2d(self.expansion*planes)
56
57 self.shortcut = nn.Sequential()
58 if stride != 1 or in_planes != self.expansion*planes:
59 self.shortcut = nn.Sequential(
60 nn.Conv2d(in_planes, self.expansion*planes,
61 kernel_size=1, stride=stride, bias=False),
62 nn.BatchNorm2d(self.expansion*planes)
63 )
64 self.relu = nn.ReLU(inplace=False)
65
66 def forward(self, x):
67 out = self.relu(self.bn1(self.conv1(x)))
68 out = self.relu(self.bn2(self.conv2(out)))
69 out = self.bn3(self.conv3(out))
70 out = out + self.shortcut(x)
71 out = self.relu(out)
72 return out
73
74
75class ResNet(nn.Module):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected