(self, depth=5, in_channels=64)
| 192 | |
| 193 | class DenseBlock(nn.Module): |
| 194 | def __init__(self, depth=5, in_channels=64): |
| 195 | super(DenseBlock, self).__init__() |
| 196 | self.depth = depth |
| 197 | self.in_channels = in_channels |
| 198 | self.pad = nn.ConstantPad2d((1, 1, 1, 0), value=0.) |
| 199 | self.twidth = 2 |
| 200 | self.kernel_size = (self.twidth, 3) |
| 201 | for i in range(self.depth): |
| 202 | dil = 2 ** i |
| 203 | pad_length = self.twidth + (dil - 1) * (self.twidth - 1) - 1 |
| 204 | #print(pad_length) |
| 205 | setattr(self, 'pad{}'.format(i + 1), nn.ConstantPad2d((1, 1, pad_length , 0), value=0.)) |
| 206 | setattr(self, 'conv{}'.format(i + 1), |
| 207 | nn.Conv2d(self.in_channels, self.in_channels, kernel_size=self.kernel_size, |
| 208 | dilation=(dil, 1))) |
| 209 | setattr(self, 'norm{}'.format(i + 1), InstantLayerNorm2d(self.in_channels)) |
| 210 | setattr(self, 'prelu{}'.format(i + 1), nn.PReLU(self.in_channels)) |
| 211 | |
| 212 | def forward(self, x): |
| 213 | skip = x |
nothing calls this directly
no test coverage detected