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

Method _make_layer

pycontrast/networks/resnet_cmc.py:137–152  ·  view source on GitHub ↗
(self, block, planes, blocks, stride=1)

Source from the content-addressed store, hash-verified

135 m.bias.data.zero_()
136
137 def _make_layer(self, block, planes, blocks, stride=1):
138 downsample = None
139 if stride != 1 or self.inplanes != planes * block.expansion:
140 downsample = nn.Sequential(
141 nn.Conv2d(self.inplanes, planes * block.expansion,
142 kernel_size=1, stride=stride, groups=2, bias=False),
143 nn.BatchNorm2d(planes * block.expansion),
144 )
145
146 layers = list([])
147 layers.append(block(self.inplanes, planes, stride, downsample))
148 self.inplanes = planes * block.expansion
149 for i in range(1, blocks):
150 layers.append(block(self.inplanes, planes))
151
152 return nn.Sequential(*layers)
153
154 def forward(self, x):
155 x1, x2 = torch.split(x, [1, 2], dim=1)

Callers 1

__init__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected