(self, in_channels, out_channels, dilation_rates=[1, 2, 4, 8])
| 204 | |
| 205 | class DilatedConvBlock(nn.Module): |
| 206 | def __init__(self, in_channels, out_channels, dilation_rates=[1, 2, 4, 8]): |
| 207 | super().__init__() |
| 208 | self.convs = nn.ModuleList([ |
| 209 | nn.Sequential( |
| 210 | nn.Conv2d(in_channels, out_channels // len(dilation_rates), 3, padding=d, dilation=d), |
| 211 | nn.BatchNorm2d(out_channels // len(dilation_rates)), |
| 212 | nn.ReLU(inplace=True) |
| 213 | ) |
| 214 | for d in dilation_rates |
| 215 | ]) |
| 216 | |
| 217 | def forward(self, x): |
| 218 | return torch.cat([conv(x) for conv in self.convs], dim=1) |