| 298 | m.bias.data.zero_() |
| 299 | |
| 300 | def _make_layer(self, block, planes, blocks, stride=1, dilation=1, norm_layer=None, |
| 301 | dropblock_prob=0.0, is_first=True): |
| 302 | downsample = None |
| 303 | if stride != 1 or self.inplanes != planes * block.expansion: |
| 304 | down_layers = [] |
| 305 | if self.avg_down: |
| 306 | if dilation == 1: |
| 307 | down_layers.append(nn.AvgPool2d(kernel_size=stride, stride=stride, |
| 308 | ceil_mode=True, count_include_pad=False)) |
| 309 | else: |
| 310 | down_layers.append(nn.AvgPool2d(kernel_size=1, stride=1, |
| 311 | ceil_mode=True, count_include_pad=False)) |
| 312 | down_layers.append(nn.Conv2d(self.inplanes, planes * block.expansion, |
| 313 | kernel_size=1, stride=1, bias=False)) |
| 314 | else: |
| 315 | down_layers.append(nn.Conv2d(self.inplanes, planes * block.expansion, |
| 316 | kernel_size=1, stride=stride, bias=False)) |
| 317 | down_layers.append(norm_layer(planes * block.expansion)) |
| 318 | downsample = nn.Sequential(*down_layers) |
| 319 | |
| 320 | layers = [] |
| 321 | if dilation == 1 or dilation == 2: |
| 322 | layers.append(block(self.inplanes, planes, stride, downsample=downsample, |
| 323 | radix=self.radix, cardinality=self.cardinality, |
| 324 | bottleneck_width=self.bottleneck_width, |
| 325 | avd=self.avd, avd_first=self.avd_first, |
| 326 | dilation=1, is_first=is_first, rectified_conv=self.rectified_conv, |
| 327 | rectify_avg=self.rectify_avg, |
| 328 | norm_layer=norm_layer, dropblock_prob=dropblock_prob, |
| 329 | last_gamma=self.last_gamma)) |
| 330 | elif dilation == 4: |
| 331 | layers.append(block(self.inplanes, planes, stride, downsample=downsample, |
| 332 | radix=self.radix, cardinality=self.cardinality, |
| 333 | bottleneck_width=self.bottleneck_width, |
| 334 | avd=self.avd, avd_first=self.avd_first, |
| 335 | dilation=2, is_first=is_first, rectified_conv=self.rectified_conv, |
| 336 | rectify_avg=self.rectify_avg, |
| 337 | norm_layer=norm_layer, dropblock_prob=dropblock_prob, |
| 338 | last_gamma=self.last_gamma)) |
| 339 | else: |
| 340 | raise RuntimeError("=> unknown dilation size: {}".format(dilation)) |
| 341 | |
| 342 | self.inplanes = planes * block.expansion |
| 343 | for i in range(1, blocks): |
| 344 | layers.append(block(self.inplanes, planes, |
| 345 | radix=self.radix, cardinality=self.cardinality, |
| 346 | bottleneck_width=self.bottleneck_width, |
| 347 | avd=self.avd, avd_first=self.avd_first, |
| 348 | dilation=dilation, rectified_conv=self.rectified_conv, |
| 349 | rectify_avg=self.rectify_avg, |
| 350 | norm_layer=norm_layer, dropblock_prob=dropblock_prob, |
| 351 | last_gamma=self.last_gamma)) |
| 352 | |
| 353 | return nn.Sequential(*layers) |
| 354 | |
| 355 | def forward(self, x): |
| 356 | x = self.conv1(x) |