MCPcopy Create free account
hub / github.com/HobbitLong/PyContrast / Bottleneck

Class Bottleneck

pycontrast/networks/resnet_cmc.py:69–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected