| 18 | |
| 19 | |
| 20 | class _ASPPModule(nn.Module): |
| 21 | def __init__(self, inplanes, planes, kernel_size, padding, dilation, |
| 22 | BatchNorm): |
| 23 | super(_ASPPModule, self).__init__() |
| 24 | self.atrous_conv = nn.Conv2d(inplanes, |
| 25 | planes, |
| 26 | kernel_size=kernel_size, |
| 27 | stride=1, |
| 28 | padding=padding, |
| 29 | dilation=dilation, |
| 30 | bias=False) |
| 31 | self.bn = BatchNorm(planes) |
| 32 | self.relu = nn.ReLU() |
| 33 | self._init_weight() |
| 34 | |
| 35 | def forward(self, x): |
| 36 | x = self.atrous_conv(x) |
| 37 | x = self.bn(x) |
| 38 | return self.relu(x) |
| 39 | |
| 40 | def _init_weight(self): |
| 41 | for m in self.modules(): |
| 42 | if isinstance(m, nn.Conv2d): |
| 43 | torch.nn.init.kaiming_normal_(m.weight) |
| 44 | elif isinstance(m, nn.BatchNorm2d): |
| 45 | m.weight.data.fill_(1) |
| 46 | m.bias.data.zero_() |
| 47 | |
| 48 | |
| 49 | class ASPP(nn.Module): |