PyTorch-GAN vanilla GAN implementation
generative-modelsganspytorchimplementation
Abstraction: Reference PyTorch implementation of vanilla GAN on MNIST
Key points:
- Generator is a 4-block MLP (100 → 128 → 256 → 512 → 1024 → img_size^2) with BatchNorm1d and LeakyReLU(0.2); final layer uses Tanh; latent_dim default 100
- Discriminator is a 3-layer MLP (flattened image → 512 → 256 → 1) with LeakyReLU and Sigmoid output
- Loss: BCELoss; optimizer: Adam with lr=0.0002, betas=(0.5, 0.999) for both networks
- Trained on MNIST (28×28 grayscale) with batch_size=64 for 200 epochs; images saved every 400 batches
- Training loop: update generator first (fool discriminator with label=1), then update discriminator on real (label=1) and fake (label=0) images separately; discriminator loss averaged over both
- Part of the eriklindernoren/PyTorch-GAN repository covering many GAN variants
Connections: Pytorch · Github · Generative Adversarial Networks · Deep Learning
Source: https://github.com/eriklindernoren/PyTorch-GAN/blob/master/implementations/gan/gan.py