Bottleneck block for ResNeSt.
(self,
inplanes,
planes,
groups=1,
base_width=4,
base_channels=64,
radix=2,
reduction_factor=4,
avg_down_stride=True,
**kwargs)
| 164 | expansion = 4 |
| 165 | |
| 166 | def __init__(self, |
| 167 | inplanes, |
| 168 | planes, |
| 169 | groups=1, |
| 170 | base_width=4, |
| 171 | base_channels=64, |
| 172 | radix=2, |
| 173 | reduction_factor=4, |
| 174 | avg_down_stride=True, |
| 175 | **kwargs): |
| 176 | """Bottleneck block for ResNeSt.""" |
| 177 | super(Bottleneck, self).__init__(inplanes, planes, **kwargs) |
| 178 | |
| 179 | if groups == 1: |
| 180 | width = self.planes |
| 181 | else: |
| 182 | width = math.floor(self.planes * |
| 183 | (base_width / base_channels)) * groups |
| 184 | |
| 185 | self.avg_down_stride = avg_down_stride and self.conv2_stride > 1 |
| 186 | |
| 187 | self.norm1_name, norm1 = build_norm_layer( |
| 188 | self.norm_cfg, width, postfix=1) |
| 189 | self.norm3_name, norm3 = build_norm_layer( |
| 190 | self.norm_cfg, self.planes * self.expansion, postfix=3) |
| 191 | |
| 192 | self.conv1 = build_conv_layer( |
| 193 | self.conv_cfg, |
| 194 | self.inplanes, |
| 195 | width, |
| 196 | kernel_size=1, |
| 197 | stride=self.conv1_stride, |
| 198 | bias=False) |
| 199 | self.add_module(self.norm1_name, norm1) |
| 200 | self.with_modulated_dcn = False |
| 201 | self.conv2 = SplitAttentionConv2d( |
| 202 | width, |
| 203 | width, |
| 204 | kernel_size=3, |
| 205 | stride=1 if self.avg_down_stride else self.conv2_stride, |
| 206 | padding=self.dilation, |
| 207 | dilation=self.dilation, |
| 208 | groups=groups, |
| 209 | radix=radix, |
| 210 | reduction_factor=reduction_factor, |
| 211 | conv_cfg=self.conv_cfg, |
| 212 | norm_cfg=self.norm_cfg, |
| 213 | dcn=self.dcn) |
| 214 | delattr(self, self.norm2_name) |
| 215 | |
| 216 | if self.avg_down_stride: |
| 217 | self.avd_layer = nn.AvgPool2d(3, self.conv2_stride, padding=1) |
| 218 | |
| 219 | self.conv3 = build_conv_layer( |
| 220 | self.conv_cfg, |
| 221 | width, |
| 222 | self.planes * self.expansion, |
| 223 | kernel_size=1, |
nothing calls this directly
no test coverage detected