This directory contains a progression of 11 GAN implementations in TensorFlow, starting from a simple fully connected GAN and moving toward image synthesis, translation, super-resolution, and progressive variants.
The folders are ordered as a learning path:
1_InitialGAN2_DeepConvolutionalGAN3_LeastSquareGAN4_WassersteinGAN5_WassersteinGANGP6_ConditionalGAN7_CycleGAN8_StarGAN9_StyleGAN10_SRGAN11_ProgressiveGAN
Most subprojects follow the same layout:
config.pyfor hyperparametersdataset.pyfor loading and preprocessing datasetsmodel.pyfor the generator, discriminator, and training logictrain_and_test.pyas the main training entry pointrun.shin most folders for conveniencelogs/for saved weights, samples, training state, and history
Common defaults across the implementations:
- base image size:
32x32 - latent dimension:
64 - generator learning rate:
1e-4 - discriminator learning rate:
1e-4 - normalization to
[-1, 1] - sample image grids saved during training
For larger image datasets such as CelebA or anime faces, some implementations switch to larger input resolution and a larger latent space.
Folder: 1_InitialGAN
This is the most basic implementation in the collection. The generator and discriminator are primarily dense networks:
- generator: latent vector -> dense layers -> reshaped image
- discriminator: flattened image -> dense layers -> real/fake score
Training details:
- standard binary cross-entropy GAN loss
- spectral normalization is used in the discriminator dense blocks
- small Gaussian noise is added to real and generated images during discriminator training
This version is useful as a baseline because it shows the original adversarial setup without convolution-heavy architecture changes.
Folder: 2_DeepConvolutionalGAN
This version moves from fully connected image synthesis to a convolutional generator/discriminator design. The architecture uses residual-style upsampling and downsampling blocks:
- generator grows images from a learned
4x4feature map using residual upsampling blocks - discriminator reduces images using residual downsampling blocks and global pooling
Training details:
- binary cross-entropy objective
- one-sided label smoothing for real images
- Gaussian instance noise added during discriminator training
This is the first implementation in the directory that is structurally closer to practical image GANs.
Folder: 3_LeastSquareGAN
LSGAN keeps a very similar convolutional architecture to the DCGAN-style implementation, but changes the adversarial objective:
- replaces binary cross-entropy with mean squared error
- pushes real predictions toward
1and fake predictions toward0
Why this matters:
- the least-squares objective can provide smoother gradients
- it often reduces vanishing-gradient behavior compared with the original GAN loss
This implementation is useful when the standard GAN objective becomes unstable or produces weak discriminator gradients.
Folder: 4_WassersteinGAN
This implementation changes the optimization target from classification loss to Wasserstein distance estimation:
- generator loss: maximize critic score on fake samples
- critic loss: maximize the score gap between real and fake samples
Training details:
- uses a critic rather than a probability discriminator
- applies weight clipping to critic parameters
- trains the critic more times than the generator (
N_DISC_STEP = 3)
Why it exists:
- WGAN is intended to improve training stability
- critic scores are often more meaningful than BCE losses for monitoring progress
This is the classic pre-gradient-penalty Wasserstein formulation.
Folder: 5_WassersteinGANGP
This variant improves on WGAN by replacing weight clipping with gradient penalty:
- interpolates between real and fake images
- penalizes the critic when gradient norm deviates from
1 - uses
LAMBDA_GP = 10.0
Why it matters:
- more stable than clipped WGAN in many settings
- avoids the capacity and optimization issues caused by weight clipping
In this repo, the architecture is very close to the WGAN version, so the main conceptual difference is the critic regularization.
Folder: 6_ConditionalGAN
This implementation extends the WGAN-GP-style setup by conditioning both generator and discriminator on labels:
- generator takes noise and a label vector
- discriminator takes an image and the corresponding label vector
- labels are merged into the model through learned dense projections
Supported conditioning modes in the code:
- one-hot conditioning for datasets like MNIST, Fashion-MNIST, CIFAR-10, and CIFAR-100
- multi-label conditioning for CelebA using attribute annotations
This is the most expressive GAN implementation in the directory because it allows controlled generation rather than unconditional sampling.
The remaining folders also contain source-backed config.py, dataset.py,
model.py, and train_and_test.py workflows:
- CycleGAN: unpaired two-domain translation with cycle consistency.
- StarGAN: multi-domain conditional translation.
- StyleGAN: style-oriented generator and adversarial training path.
- SRGAN: super-resolution with weighted content and adversarial terms.
- ProgressiveGAN: staged/progressive image-generation workflow.
Across these folders, the dataset loaders support combinations of:
mnistfashion_mnistcifar10cifar100celebaanime_facesin the unconditional variants
Notes:
- unconditional GAN folders generally treat all images as belonging to one distribution
6_ConditionalGANuses labels explicitly- CelebA in the conditional implementation uses attribute vectors rather than single-class labels
| Folder | Main change | Loss style | Conditioning |
|---|---|---|---|
1_InitialGAN |
Dense baseline GAN | BCE | No |
2_DeepConvolutionalGAN |
Convolutional / residual image generator | BCE | No |
3_LeastSquareGAN |
Least-squares objective | MSE | No |
4_WassersteinGAN |
Wasserstein critic + weight clipping | Wasserstein | No |
5_WassersteinGANGP |
Gradient penalty instead of clipping | Wasserstein + GP | No |
6_ConditionalGAN |
Label-conditioned generation | Wasserstein + GP style critic training | Yes |
7_CycleGAN |
Unpaired domain translation | Adversarial + cycle consistency | Domain |
8_StarGAN |
Multi-domain translation | Conditional adversarial | Domain |
9_StyleGAN |
Style-oriented synthesis | Adversarial | No |
10_SRGAN |
Image super-resolution | Content + adversarial | Input image |
11_ProgressiveGAN |
Progressive synthesis | Adversarial | No |
From inside any GAN subfolder, the common training pattern is:
python train_and_test.py --gpu -1 --type cifar10Common dataset examples:
python train_and_test.py --gpu 0 --type mnist
python train_and_test.py --gpu 0 --type fashion_mnist
python train_and_test.py --gpu 0 --type cifar10
python train_and_test.py --gpu 0 --type celebaEvery run.sh passes --continue, so an interrupted run resumes from its
saved epoch and restores the full TensorFlow checkpoint, including optimizer
state. Running train_and_test.py without --continue still loads compatible
saved weights when present, but starts the epoch counter from zero. --resume
is retained as an alias for --continue.
Across all models, BATCH_SIZE is the global batch size and must be divisible
by the number of replicas. Training uses replica-local batches, globally scaled
losses, epoch-averaged loss reporting, TensorFlow/Keras progress bars, fixed
preview inputs, and exponential-moving-average generator weights for saved
samples. Dataset pipelines stream from their source and do not use a generated
cache.
Use these plain markers when recording real training results:
Y: the dataset completed training and generated outputs passed visual and model-appropriate quality checks.N: the completed run demonstrably collapsed or failed its quality checks.?: incomplete, missing comparable metrics, or not yet verified.
A successful compile, one-batch smoke test, finite loss, or completed epoch is
not by itself convergence evidence. Keep a dataset at ? until its fixed sample
sequence and an appropriate metric (for example FID/KID, or PSNR/SSIM for
SRGAN) have been reviewed.
Each implementation saves a mix of:
generator.weights.h5discriminator.weights.h5training_state.jsonhistory.json- generated sample grids under
logs/.../samples/ - a final generated grid after training
Some folders also include architecture diagrams such as generator.png and discriminator.png.
If you want to study the evolution of GAN training in this repo, the best order is:
1_InitialGANto understand the original adversarial setup2_DeepConvolutionalGANto see why convolutional generators work better for images3_LeastSquareGANto understand how changing the loss affects stability4_WassersteinGANto move from classifier-based discrimination to critic-based training5_WassersteinGANGPto see the more stable Wasserstein formulation6_ConditionalGANto add controllable generation7_CycleGANand8_StarGANfor domain translation9_StyleGAN,10_SRGAN, and11_ProgressiveGANfor specialised generation
- The directory name is spelled
GenerativeAdvesarialNetworksin the repo, so commands and paths need to use that exact spelling. - The implementations are research/learning code and save many artifacts directly into local
logs/folders. - There is shared design reuse across later folders, especially from DCGAN -> LSGAN -> WGAN -> WGAN-GP.
If you want, the next useful step would be to add per-folder README files with exact architecture notes, supported datasets, and example results for each GAN individually.