What should be the architecture of the generator and discriminator model of the GAN for generating 300 * 300 * 3 images?
I have usually seen people generating images of 28 * 28 , 64 * 64 etc. For creating this sized image they usually start with the number of filters 512, 256, 128,.. so on in decreasing manner for generators and for discriminators in reverse manner. Usually they keep the same number of layers in discriminator and generators.
My first question is what should be the architecture of discriminator and generator model to create 300 * 300 images.
My second question is ..is it mandatory to have equal number of layers in both the discriminator and generator. What if I have more number of layers in my discriminator than the generator ?
My third question depends upon the second question only, can I use feature extractor part of any famous models like resnet , vgg etc. for making discriminators ?
P.S. if you are writing the architecture code please make it in pytorch or keras .


The architecture of the Generator is completely dependent on the resolution of the image that you desire. If you need to output a higher resolution image, you need to modify the kernel_size, stride, and padding of the ConvTranspose2d layers accordingly. See the below example:

# 64 * 64 * 3
# Assuming a latent dimension of 128, you will perform the following sequence to generate a 64*64*3 image.

latent = torch.randn(1, 128, 1, 1)

out = nn.ConvTranspose2d(128, 512, 4, 1)(latent)
out = nn.ConvTranspose2d(512, 256, 4, 2, 1)(out)
out = nn.ConvTranspose2d(256, 128, 4, 2, 1)(out)
out = nn.ConvTranspose2d(128, 64, 4, 2, 1)(out)
out = nn.ConvTranspose2d(64, 3, 4, 2, 1)(out)
print(out.shape) # torch.Size([1, 3, 64, 64])

# Note the values of the kernel_size, stride, and padding.

# 284 * 284 * 3
# Assuming the same latent dimension of 128, you will perform the following sequence to generate a 284*284*3 image.

latent = torch.randn(1, 128, 1, 1)

out = nn.ConvTranspose2d(128, 512, 4, 1)(latent)
out = nn.ConvTranspose2d(512, 256, 4, 3, 1)(out)
out = nn.ConvTranspose2d(256, 128, 4, 3, 1)(out)
out = nn.ConvTranspose2d(128, 64, 4, 3, 1)(out)
out = nn.ConvTranspose2d(64, 3, 4, 3, 1)(out)
print(out.shape) # torch.Size([1, 3, 284, 284])

# I have only increased the stride from 2 to 3 and you could see the difference in the output size. You can play with the values to get 300*300*3.

If you would like to generate a higher sized output, take a look at progressive GANs.

The general idea behind using symmetric layers in both the Generator and the Discriminator is that you want both the networks to be equally powerful. They compete against themselves and learn over time. Having asymmetric layers could cause imbalance while training.

Yes. You can use any feature extractor instead of the basic Conv and ConvTranspose layers. You can use the ResidualBlock as part of the encoder and ResidualBlockUp as part of the decoder.


