MCPcopy Create free account
hub / github.com/SLDGroup/EMCAD / Bottleneck

Class Bottleneck

lib/resnet.py:64–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62
63
64class Bottleneck(nn.Module):
65 expansion = 4
66
67 def __init__(self, inplanes, planes, stride=1, downsample=None):
68 super(Bottleneck, self).__init__()
69 self.conv1 = nn.Conv2d(inplanes, planes, kernel_size=1, bias=False)
70 self.bn1 = nn.BatchNorm2d(planes)
71 self.conv2 = nn.Conv2d(planes, planes, kernel_size=3, stride=stride,
72 padding=1, bias=False)
73 self.bn2 = nn.BatchNorm2d(planes)
74 self.conv3 = nn.Conv2d(planes, planes * Bottleneck.expansion, kernel_size=1, bias=False)
75 self.bn3 = nn.BatchNorm2d(planes * Bottleneck.expansion)
76 self.relu = nn.ReLU(inplace=True)
77 self.downsample = downsample
78 self.stride = stride
79
80 def forward(self, x):
81 residual = x
82
83 out = self.conv1(x)
84 out = self.bn1(out)
85 out = self.relu(out)
86
87 out = self.conv2(out)
88 out = self.bn2(out)
89 out = self.relu(out)
90
91 out = self.conv3(out)
92 out = self.bn3(out)
93
94 if self.downsample is not None:
95 residual = self.downsample(x)
96
97 out += residual
98 out = self.relu(out)
99
100 return out
101
102
103class ResNet(nn.Module):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected