Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

Simple GAN with PyTorch

This repository contains a basic implementation of a Generative Adversarial Network (GAN) using PyTorch, designed to generate handwritten digits similar to the MNIST dataset.


Overview

  • Generator (G): Takes random noise as input and tries to produce realistic-looking MNIST digit images.
  • Discriminator (D): Attempts to distinguish between real MNIST images and the fake images generated by the Generator.
  • Both models are trained together in a zero-sum game — G tries to fool D, while D tries not to be fooled.

Files

  • GAN.ipynb — Colab notebook with the full PyTorch code for:

    • Loading the MNIST dataset.
    • Defining the Generator and Discriminator networks.
    • Training loop with logging to TensorBoard.

Requirements

  • Python 3
  • PyTorch
  • Torchvision
  • TensorBoard

You can install dependencies using:

pip install torch torchvision tensorboard

How to Run

  1. Open in Colab: Open In Colab

  2. Run the notebook cells:

    • The notebook will download MNIST automatically.
    • The GAN will train for 50 epochs (by default).
  3. Monitor progress:

    • Generated fake images and real samples are logged to TensorBoard.
    • Run tensorboard --logdir=logs to see them.

Training Details

  • Latent Vector (z-dim): 64
  • Image Dimension: 28×28 = 784
  • Optimizer: Adam (lr = 3e-4)
  • Loss: Binary Cross Entropy (BCE)

Output

  • During training, you can visually compare real vs. generated images.
  • Over time, fake images should look more realistic.

About

This repository contains a basic implementation of a Generative Adversarial Network (GAN) using PyTorch, designed to generate handwritten digits similar to the MNIST dataset.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages