(self, x)
| 202 | |
| 203 | |
| 204 | def forward(self, x): |
| 205 | #assert x.shape[2] == x.shape[3] == self.resolution, "{}, {}, {}".format(x.shape[2], x.shape[3], self.resolution) |
| 206 | |
| 207 | # timestep embedding |
| 208 | temb = None |
| 209 | |
| 210 | # downsampling |
| 211 | hs = [self.conv_in(x)] |
| 212 | for i_level in range(self.num_resolutions): |
| 213 | for i_block in range(self.num_res_blocks): |
| 214 | h = self.down[i_level].block[i_block](hs[-1], temb) |
| 215 | hs.append(h) |
| 216 | if i_level != self.num_resolutions-1: |
| 217 | hs.append(self.down[i_level].downsample(hs[-1])) |
| 218 | |
| 219 | # middle |
| 220 | h = hs[-1] |
| 221 | h = self.mid.block_1(h, temb) |
| 222 | h = self.mid.block_2(h, temb) |
| 223 | |
| 224 | # end |
| 225 | h = self.norm_out(h) |
| 226 | h = nonlinearity(h) |
| 227 | h = self.conv_out(h) |
| 228 | return h |
| 229 | |
| 230 | |
| 231 | class Decoder(nn.Module): |
nothing calls this directly
no test coverage detected