Three GAN variants implemented with PyTorch, PyTorch Lightning, and Hydra: a fully connected GAN, a convolutional DCGAN, and a label-conditioned GAN. The repository includes training code and saved sample grids for MNIST, CIFAR-10, and Fashion-MNIST.
Requires Python 3.11+ and uv. The training wrappers currently set accelerator="mps", so the default command requires an available Apple MPS device. To use CPU or CUDA, change the trainer accelerator in src/training/train.py. Dataset loaders download data into ./data when it is not already present.
# Install dependencies
uv sync
# Configure which model to train
# Edit src/config/config.yaml, for example:
# model: gan # or cgan, dcgan
# epochs: 100
# Run training
uv run python -m src.main- Vanilla GAN - Basic adversarial training on MNIST
- DCGAN - Convolutional architecture for CIFAR-10
- Conditional GAN - Label-conditioned generation on Fashion-MNIST
The grids below are saved outputs labeled by epoch. They provide examples of generated images, not a quantitative evaluation of quality or a reproduction of published benchmark results. The training configuration defaults to 100 epochs.
32x32 RGB Images
| Epoch 0 | Epoch 30 | Epoch 60 | Epoch 90 |
|---|---|---|---|
![]() |
![]() |
![]() |
![]() |
28x28 Grayscale
| Epoch 0 | Epoch 30 | Epoch 60 | Epoch 90 |
|---|---|---|---|
![]() |
![]() |
![]() |
![]() |
28x28 Grayscale + Labels
| Epoch 0 | Epoch 30 | Epoch 60 | Epoch 90 |
|---|---|---|---|
![]() |
![]() |
![]() |
![]() |
- Model Implementations: Fully connected, convolutional, and conditional GAN variants
- Multiple Datasets: MNIST, Fashion-MNIST, CIFAR-10
- Real-time Monitoring: Progress displayed every epoch
- Image Generation: Results saved every 10 epochs
gan-architectures-from-scratch-pytorch/
├── results/ # Generated images (saved every 10 epochs)
│ ├── gan/ # Vanilla GAN outputs
│ ├── dcgan/ # DCGAN outputs
│ └── cgan/ # Conditional GAN outputs
└── src/
├── main.py # Training entry point (reads src/config/config.yaml)
├── config/
│ └── config.yaml # Minimal config: model, epochs
├── models/ # GAN architectures (LightningModule)
│ ├── gan.py # Vanilla GAN
│ ├── dcgan.py # Deep Convolutional GAN
│ └── cgan.py # Conditional GAN
├── training/
│ ├── train.py # Trainer wrappers (PyTorch Lightning)
│ └── loss.py # Loss functions
├── data/
│ └── data.py # Dataset loaders
└── utils/
└── utils.py # Helper functions
- Vanilla GAN: MLP → 784 outputs (28×28)
- DCGAN: ConvTranspose2d → 32×32×3 RGB
- Conditional GAN: MLP with concatenated one-hot class labels → 784 outputs
- Optimizer: Adam (lr=0.0002)
- Loss: Binary cross entropy for the discriminator and a non-saturating generator loss (fake samples are assigned real targets for the generator update)
- Batch Size: 100
- Epochs: 100 by default; configurable in
src/config/config.yaml - Device: MPS is hard-coded in the training wrappers; CPU/CUDA requires changing the accelerator
- The saved grids show outputs for the three model/dataset combinations above. The repository does not report quantitative image-quality metrics.
- The conditional model takes one-hot class labels during training and sample generation; its saved grids use randomly sampled labels and do not measure class consistency.
- These are implementations of the model families described in the papers below, with local architecture and training choices. They do not establish exact reproduction of the papers' architectures or results.
git clone https://github.com/00200200/gan-architectures-from-scratch-pytorch
cd gan-architectures-from-scratch-pytorch
uv sync# Select model in config
# src/config/config.yaml
# model: gan # or cgan, dcgan
# epochs: 100
# Run
uv run python -m src.main
# Results are saved under results/<model>/ every 10 epochsSample grids are saved every 10 epochs in results/<model>/, starting at epoch index 0. Each grid uses newly sampled noise; conditional grids also use newly sampled labels. They are not fixed-input comparisons across epochs.
- GAN: Generative Adversarial Networks (Goodfellow et al., 2014)
- DCGAN: Deep Convolutional GANs (Radford et al., 2015)
- CGAN: Conditional GANs (Mirza & Osindero, 2014)
PyTorch defines the models; PyTorch Lightning handles the training loop and Hydra handles configuration.











