| 569 | |
| 570 | |
| 571 | class SimpleDecoder(nn.Module): |
| 572 | def __init__(self, in_channels, out_channels, *args, **kwargs): |
| 573 | super().__init__() |
| 574 | self.model = nn.ModuleList([nn.Conv2d(in_channels, in_channels, 1), |
| 575 | ResnetBlock(in_channels=in_channels, |
| 576 | out_channels=2 * in_channels, |
| 577 | temb_channels=0, dropout=0.0), |
| 578 | ResnetBlock(in_channels=2 * in_channels, |
| 579 | out_channels=4 * in_channels, |
| 580 | temb_channels=0, dropout=0.0), |
| 581 | ResnetBlock(in_channels=4 * in_channels, |
| 582 | out_channels=2 * in_channels, |
| 583 | temb_channels=0, dropout=0.0), |
| 584 | nn.Conv2d(2*in_channels, in_channels, 1), |
| 585 | Upsample(in_channels, with_conv=True)]) |
| 586 | # end |
| 587 | self.norm_out = Normalize(in_channels) |
| 588 | self.conv_out = torch.nn.Conv2d(in_channels, |
| 589 | out_channels, |
| 590 | kernel_size=3, |
| 591 | stride=1, |
| 592 | padding=1) |
| 593 | |
| 594 | def forward(self, x): |
| 595 | for i, layer in enumerate(self.model): |
| 596 | if i in [1,2,3]: |
| 597 | x = layer(x, None) |
| 598 | else: |
| 599 | x = layer(x) |
| 600 | |
| 601 | h = self.norm_out(x) |
| 602 | h = nonlinearity(h) |
| 603 | x = self.conv_out(h) |
| 604 | return x |
| 605 | |
| 606 | |
| 607 | class UpsampleDecoder(nn.Module): |
nothing calls this directly
no outgoing calls
no test coverage detected