MCPcopy Create free account
hub / github.com/alinlab/SelfPatch / _make_layer

Method _make_layer

segmentation/backbones/hrnet.py:481–527  ·  view source on GitHub ↗

Make each layer.

(self, block, inplanes, planes, blocks, stride=1)

Source from the content-addressed store, hash-verified

479 return nn.ModuleList(transition_layers)
480
481 def _make_layer(self, block, inplanes, planes, blocks, stride=1):
482 """Make each layer."""
483 downsample = None
484 if stride != 1 or inplanes != planes * block.expansion:
485 downsample = nn.Sequential(
486 build_conv_layer(
487 self.conv_cfg,
488 inplanes,
489 planes * block.expansion,
490 kernel_size=1,
491 stride=stride,
492 bias=False),
493 build_norm_layer(self.norm_cfg, planes * block.expansion)[1])
494
495 layers = []
496 block_init_cfg = None
497 if self.pretrained is None and not hasattr(
498 self, 'init_cfg') and self.zero_init_residual:
499 if block is BasicBlock:
500 block_init_cfg = dict(
501 type='Constant', val=0, override=dict(name='norm2'))
502 elif block is Bottleneck:
503 block_init_cfg = dict(
504 type='Constant', val=0, override=dict(name='norm3'))
505
506 layers.append(
507 block(
508 inplanes,
509 planes,
510 stride,
511 downsample=downsample,
512 with_cp=self.with_cp,
513 norm_cfg=self.norm_cfg,
514 conv_cfg=self.conv_cfg,
515 init_cfg=block_init_cfg))
516 inplanes = planes * block.expansion
517 for i in range(1, blocks):
518 layers.append(
519 block(
520 inplanes,
521 planes,
522 with_cp=self.with_cp,
523 norm_cfg=self.norm_cfg,
524 conv_cfg=self.conv_cfg,
525 init_cfg=block_init_cfg))
526
527 return Sequential(*layers)
528
529 def _make_stage(self, layer_config, in_channels, multiscale_output=True):
530 """Make each stage."""

Callers 1

__init__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected