| 286 | |
| 287 | |
| 288 | class ResidualConv(nn.Module): |
| 289 | def __init__(self, inchannels): |
| 290 | super(ResidualConv, self).__init__() |
| 291 | # NN.BatchNorm2d |
| 292 | self.conv = nn.Sequential( |
| 293 | # nn.BatchNorm2d(num_features=inchannels), |
| 294 | nn.ReLU(inplace=False), |
| 295 | # nn.Conv2d(in_channels=inchannels, out_channels=inchannels, kernel_size=3, padding=1, stride=1, groups=inchannels,bias=True), |
| 296 | # nn.Conv2d(in_channels=inchannels, out_channels=inchannels, kernel_size=1, padding=0, stride=1, groups=1,bias=True) |
| 297 | nn.Conv2d(in_channels=inchannels, out_channels=inchannels / 2, kernel_size=3, padding=1, stride=1, |
| 298 | bias=False), |
| 299 | nn.BatchNorm2d(num_features=inchannels / 2), |
| 300 | nn.ReLU(inplace=False), |
| 301 | nn.Conv2d(in_channels=inchannels / 2, out_channels=inchannels, kernel_size=3, padding=1, stride=1, |
| 302 | bias=False) |
| 303 | ) |
| 304 | self.init_params() |
| 305 | |
| 306 | def forward(self, x): |
| 307 | x = self.conv(x) + x |
| 308 | return x |
| 309 | |
| 310 | def init_params(self): |
| 311 | for m in self.modules(): |
| 312 | if isinstance(m, nn.Conv2d): |
| 313 | # init.kaiming_normal_(m.weight, mode='fan_out') |
| 314 | init.normal_(m.weight, std=0.01) |
| 315 | # init.xavier_normal_(m.weight) |
| 316 | if m.bias is not None: |
| 317 | init.constant_(m.bias, 0) |
| 318 | elif isinstance(m, nn.ConvTranspose2d): |
| 319 | # init.kaiming_normal_(m.weight, mode='fan_out') |
| 320 | init.normal_(m.weight, std=0.01) |
| 321 | # init.xavier_normal_(m.weight) |
| 322 | if m.bias is not None: |
| 323 | init.constant_(m.bias, 0) |
| 324 | elif isinstance(m, nn.BatchNorm2d): # NN.BatchNorm2d |
| 325 | init.constant_(m.weight, 1) |
| 326 | init.constant_(m.bias, 0) |
| 327 | elif isinstance(m, nn.Linear): |
| 328 | init.normal_(m.weight, std=0.01) |
| 329 | if m.bias is not None: |
| 330 | init.constant_(m.bias, 0) |
| 331 | |
| 332 | |
| 333 | class FeatureFusion(nn.Module): |