| 190 | nn.init.constant_(m.bn2.weight, 0) |
| 191 | |
| 192 | def _make_layer(self, block, planes, blocks, stride=1, dilate=False): |
| 193 | norm_layer = self._norm_layer |
| 194 | downsample = None |
| 195 | previous_dilation = self.dilation |
| 196 | if dilate: |
| 197 | self.dilation *= stride |
| 198 | stride = 1 |
| 199 | if stride != 1 or self.inplanes != planes * block.expansion: |
| 200 | downsample = nn.Sequential( |
| 201 | conv1x1(self.inplanes, planes * block.expansion, stride), |
| 202 | norm_layer(planes * block.expansion), |
| 203 | ) |
| 204 | |
| 205 | layers = [] |
| 206 | layers.append(block(self.inplanes, planes, stride, downsample, self.groups, |
| 207 | self.base_width, previous_dilation, norm_layer)) |
| 208 | self.inplanes = planes * block.expansion |
| 209 | for _ in range(1, blocks): |
| 210 | layers.append(block(self.inplanes, planes, groups=self.groups, |
| 211 | base_width=self.base_width, dilation=self.dilation, |
| 212 | norm_layer=norm_layer)) |
| 213 | |
| 214 | return nn.Sequential(*layers) |
| 215 | |
| 216 | def _forward_impl(self, x): |
| 217 | # See note [TorchScript super()] |