(self, x)
| 136 | self.conv = conv_nd(dims, self.channels, self.out_channels, 3, padding=padding) |
| 137 | |
| 138 | def forward(self, x): |
| 139 | assert x.shape[1] == self.channels |
| 140 | if self.dims == 3: |
| 141 | t_factor = 1 if not self.third_up else 2 |
| 142 | x = F.interpolate( |
| 143 | x, |
| 144 | (t_factor * x.shape[2], x.shape[3] * 2, x.shape[4] * 2), |
| 145 | mode="nearest", |
| 146 | ) |
| 147 | else: |
| 148 | x = F.interpolate(x, scale_factor=2, mode="nearest") |
| 149 | if self.use_conv: |
| 150 | x = self.conv(x) |
| 151 | return x |
| 152 | |
| 153 | |
| 154 | class TransposedUpsample(nn.Module): |