| 40 | |
| 41 | |
| 42 | class Upsample(nn.Module): |
| 43 | def __init__(self, in_channels, with_conv): |
| 44 | super().__init__() |
| 45 | self.with_conv = with_conv |
| 46 | if self.with_conv: |
| 47 | self.conv = torch.nn.Conv2d(in_channels, |
| 48 | in_channels, |
| 49 | kernel_size=3, |
| 50 | stride=1, |
| 51 | padding=1) |
| 52 | |
| 53 | def forward(self, x): |
| 54 | x = torch.nn.functional.interpolate(x, scale_factor=2.0, mode="nearest") |
| 55 | if self.with_conv: |
| 56 | x = self.conv(x) |
| 57 | return x |
| 58 | |
| 59 | |
| 60 | class Downsample(nn.Module): |