| 76 | |
| 77 | |
| 78 | class Upsample(nn.Module): |
| 79 | def __init__(self, in_channels, with_conv): |
| 80 | super().__init__() |
| 81 | self.with_conv = with_conv |
| 82 | if self.with_conv: |
| 83 | self.conv = torch.nn.Conv2d(in_channels, in_channels, kernel_size=3, stride=1, padding=1) |
| 84 | |
| 85 | def forward(self, x): |
| 86 | x = torch.nn.functional.interpolate(x, scale_factor=2.0, mode="nearest") |
| 87 | if self.with_conv: |
| 88 | x = self.conv(x) |
| 89 | return x |
| 90 | |
| 91 | |
| 92 | class Downsample(nn.Module): |