aladdinpersson / Machine-Learning-Collection

A resource for learning about Machine learning & Deep Learning
https://www.youtube.com/c/AladdinPersson
MIT License
7.69k stars 2.7k forks source link

ConvBlock for Discriminator #168

Open Rainyryan opened 1 year ago

Rainyryan commented 1 year ago

In the original paper Upsample is done prior to the convolutions in the Generator, while Downsample is done after the convolutions within the ConvBlock.

I believe the following changes should be appropriate.

I discovered large discrepancies when checking the number of parameters for each layer in D and G. Unlike in the paper where D and G have same number of parameters.

class ConvBlock(nn.Module):
    def __init__(self, in_channels, out_channels, use_pixelnorm=True, isgen=True):
        super(ConvBlock, self).__init__()
        self.use_pn = use_pixelnorm
        self.conv1 = WSConv2d(
            in_channels, out_channels if isgen else in_channels) <<<<<<<<
        self.conv2 = WSConv2d(
            out_channels if isgen else in_channels, out_channels)<<<<<<<<
        self.leaky = nn.LeakyReLU(0.2)
        self.pn = PixelNorm()