(self, n_upsample, n_res, dim, output_dim, norm='batch', activ='relu', pad_type='zero', nz=0)
| 748 | |
| 749 | class Decoder(nn.Module): |
| 750 | def __init__(self, n_upsample, n_res, dim, output_dim, norm='batch', activ='relu', pad_type='zero', nz=0): |
| 751 | super(Decoder, self).__init__() |
| 752 | |
| 753 | self.model = [] |
| 754 | # AdaIN residual blocks |
| 755 | self.model += [ResBlocks(n_res, dim, norm, activ, pad_type=pad_type, nz=nz)] |
| 756 | # upsampling blocks |
| 757 | for i in range(n_upsample): |
| 758 | if i == 0: |
| 759 | input_dim = dim + nz |
| 760 | else: |
| 761 | input_dim = dim |
| 762 | self.model += [Upsample2(scale_factor=2), Conv2dBlock(input_dim, dim // 2, 5, 1, 2, norm='ln', activation=activ, pad_type='reflect')] |
| 763 | dim //= 2 |
| 764 | # use reflection padding in the last conv layer |
| 765 | self.model += [Conv2dBlock(dim, output_dim, 7, 1, 3, norm='none', activation='tanh', pad_type='reflect')] |
| 766 | self.model = nn.Sequential(*self.model) |
| 767 | |
| 768 | def forward(self, x, y=None): |
| 769 | if y is not None: |
nothing calls this directly
no test coverage detected