| 692 | |
| 693 | |
| 694 | class SimpleDecoder(nn.Module): |
| 695 | def __init__(self, in_channels, out_channels, *args, **kwargs): |
| 696 | super().__init__() |
| 697 | self.model = nn.ModuleList([nn.Conv2d(in_channels, in_channels, 1), |
| 698 | ResnetBlock(in_channels=in_channels, |
| 699 | out_channels=2 * in_channels, |
| 700 | temb_channels=0, dropout=0.0), |
| 701 | ResnetBlock(in_channels=2 * in_channels, |
| 702 | out_channels=4 * in_channels, |
| 703 | temb_channels=0, dropout=0.0), |
| 704 | ResnetBlock(in_channels=4 * in_channels, |
| 705 | out_channels=2 * in_channels, |
| 706 | temb_channels=0, dropout=0.0), |
| 707 | nn.Conv2d(2*in_channels, in_channels, 1), |
| 708 | Upsample(in_channels, with_conv=True)]) |
| 709 | # end |
| 710 | self.norm_out = Normalize(in_channels) |
| 711 | self.conv_out = torch.nn.Conv2d(in_channels, |
| 712 | out_channels, |
| 713 | kernel_size=3, |
| 714 | stride=1, |
| 715 | padding=1) |
| 716 | |
| 717 | def forward(self, x): |
| 718 | for i, layer in enumerate(self.model): |
| 719 | if i in [1,2,3]: |
| 720 | x = layer(x, None) |
| 721 | else: |
| 722 | x = layer(x) |
| 723 | |
| 724 | h = self.norm_out(x) |
| 725 | h = nonlinearity(h) |
| 726 | x = self.conv_out(h) |
| 727 | return x |
| 728 | |
| 729 | |
| 730 | class UpsampleDecoder(nn.Module): |
nothing calls this directly
no outgoing calls
no test coverage detected