(self, in_channels, out_channels, ch, num_res_blocks, resolution,
ch_mult=(2,2), dropout=0.0)
| 736 | |
| 737 | class UpsampleDecoder(nn.Module): |
| 738 | def __init__(self, in_channels, out_channels, ch, num_res_blocks, resolution, |
| 739 | ch_mult=(2,2), dropout=0.0): |
| 740 | super().__init__() |
| 741 | # upsampling |
| 742 | self.temb_ch = 0 |
| 743 | self.num_resolutions = len(ch_mult) |
| 744 | self.num_res_blocks = num_res_blocks |
| 745 | block_in = in_channels |
| 746 | curr_res = resolution // 2 ** (self.num_resolutions - 1) |
| 747 | self.res_blocks = nn.ModuleList() |
| 748 | self.upsample_blocks = nn.ModuleList() |
| 749 | for i_level in range(self.num_resolutions): |
| 750 | res_block = [] |
| 751 | block_out = ch * ch_mult[i_level] |
| 752 | for i_block in range(self.num_res_blocks + 1): |
| 753 | res_block.append(ResnetBlock(in_channels=block_in, |
| 754 | out_channels=block_out, |
| 755 | temb_channels=self.temb_ch, |
| 756 | dropout=dropout)) |
| 757 | block_in = block_out |
| 758 | self.res_blocks.append(nn.ModuleList(res_block)) |
| 759 | if i_level != self.num_resolutions - 1: |
| 760 | self.upsample_blocks.append(Upsample(block_in, True)) |
| 761 | curr_res = curr_res * 2 |
| 762 | |
| 763 | # end |
| 764 | self.norm_out = Normalize(block_in) |
| 765 | self.conv_out = torch.nn.Conv2d(block_in, |
| 766 | out_channels, |
| 767 | kernel_size=3, |
| 768 | stride=1, |
| 769 | padding=1) |
| 770 | |
| 771 | def forward(self, x): |
| 772 | # upsampling |
nothing calls this directly
no test coverage detected