(self, x)
| 169 | self.conv = conv_nd(dims, self.channels, self.out_channels, 3, padding=1) |
| 170 | |
| 171 | def forward(self, x): |
| 172 | assert x.shape[1] == self.channels |
| 173 | if self.dims == 3: |
| 174 | x = F.interpolate( |
| 175 | x, (x.shape[2], x.shape[3] * 2, x.shape[4] * 2), mode="nearest" |
| 176 | ) |
| 177 | else: |
| 178 | x = F.interpolate(x, scale_factor=2, mode="nearest") |
| 179 | if self.use_conv: |
| 180 | x = self.conv(x) |
| 181 | return x |
| 182 | |
| 183 | |
| 184 | class Downsample(nn.Module): |