MCPcopy Create free account
hub / github.com/MotrixLab/AiOS / _make_one_branch

Method _make_one_branch

detrsmpl/models/backbones/hrnet.py:66–107  ·  view source on GitHub ↗
(self,
                         branch_index,
                         block,
                         num_blocks,
                         num_channels,
                         stride=1)

Source from the content-addressed store, hash-verified

64 raise ValueError(error_msg)
65
66 def _make_one_branch(self,
67 branch_index,
68 block,
69 num_blocks,
70 num_channels,
71 stride=1):
72 downsample = None
73 if stride != 1 or \
74 self.in_channels[branch_index] != \
75 num_channels[branch_index] * block.expansion:
76 downsample = nn.Sequential(
77 build_conv_layer(self.conv_cfg,
78 self.in_channels[branch_index],
79 num_channels[branch_index] * block.expansion,
80 kernel_size=1,
81 stride=stride,
82 bias=False),
83 build_norm_layer(self.norm_cfg, num_channels[branch_index] *
84 block.expansion)[1])
85
86 layers = []
87 layers.append(
88 block(self.in_channels[branch_index],
89 num_channels[branch_index],
90 stride,
91 downsample=downsample,
92 with_cp=self.with_cp,
93 norm_cfg=self.norm_cfg,
94 conv_cfg=self.conv_cfg,
95 init_cfg=self.block_init_cfg))
96 self.in_channels[branch_index] = \
97 num_channels[branch_index] * block.expansion
98 for i in range(1, num_blocks[branch_index]):
99 layers.append(
100 block(self.in_channels[branch_index],
101 num_channels[branch_index],
102 with_cp=self.with_cp,
103 norm_cfg=self.norm_cfg,
104 conv_cfg=self.conv_cfg,
105 init_cfg=self.block_init_cfg))
106
107 return Sequential(*layers)
108
109 def _make_branches(self, num_branches, block, num_blocks, num_channels):
110 branches = []

Callers 1

_make_branchesMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected