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

Method _make_layer

pycontrast/networks/resnet.py:185–207  ·  view source on GitHub ↗
(self, block, planes, blocks, stride=1, dilate=False)

Source from the content-addressed store, hash-verified

183 nn.init.constant_(m.bn2.weight, 0)
184
185 def _make_layer(self, block, planes, blocks, stride=1, dilate=False):
186 norm_layer = self._norm_layer
187 downsample = None
188 previous_dilation = self.dilation
189 if dilate:
190 self.dilation *= stride
191 stride = 1
192 if stride != 1 or self.inplanes != planes * block.expansion:
193 downsample = nn.Sequential(
194 conv1x1(self.inplanes, planes * block.expansion, stride),
195 norm_layer(planes * block.expansion),
196 )
197
198 layers = []
199 layers.append(block(self.inplanes, planes, stride, downsample, self.groups,
200 self.base_width, previous_dilation, norm_layer))
201 self.inplanes = planes * block.expansion
202 for _ in range(1, blocks):
203 layers.append(block(self.inplanes, planes, groups=self.groups,
204 base_width=self.base_width, dilation=self.dilation,
205 norm_layer=norm_layer))
206
207 return nn.Sequential(*layers)
208
209 def forward(self, x):
210 x = self.conv1(x)

Callers 1

__init__Method · 0.95

Calls 1

conv1x1Function · 0.85

Tested by

no test coverage detected