GithubHelp home page GithubHelp logo

ahmed-habashy / wgan-for-generating-handwritten-digits Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 5 KB

This code is an implementation of the Wasserstein GAN (WGAN) algorithm for generating handwritten digits. The WGAN algorithm was introduced as a way to address the problem of training instability in the original GAN algorithm.

Python 100.00%
ai gan gans minst wgan wgan-gp-keras

wgan-for-generating-handwritten-digits's Introduction

WGAN-for-Generating-Handwritten-Digits

This code is an implementation of the Wasserstein GAN (WGAN) algorithm for generating handwritten digits. The WGAN algorithm was introduced as a way to address the problem of training instability in the original GAN algorithm. This code contains an implementation of a Wasserstein Generative Adversarial Network (WGAN) used to generate handwritten digits from the MNIST dataset. The WGAN is a variant of GAN that uses the Wasserstein distance metric instead of the traditional Jenson-Shannon divergence for training the generator and the critic networks.

The code is written in Python and uses the Keras deep learning library with the Tensorflow backend.

Prerequisites

Python 3.x NumPy Keras TensorFlow Matplotlib

Files

wgan_handwritten_digits.py: The main script containing the implementation of the WGAN model. README.md: This file.

Usage

To run the script, simply execute the following command:

python wgan_handwritten_digits.py

By default, the script will generate 25,000 new handwritten digits and save them in the 'generated_images' folder. The script also saves the generator and critic models after training for later use.

Model Architecture

The WGAN consists of two networks: a generator network and a critic network.

The critic network is a convolutional neural network (CNN) that takes as input a 28x28 grayscale image and outputs a single scalar value. The architecture of the critic consists of two convolutional layers with 64 filters each, followed by two fully connected layers. The layers are activated using the LeakyReLU activation function and the weights are clipped to a hypercube to enforce the Lipschitz constraint. The critic is trained to maximize the Wasserstein distance between the real and generated images.

The generator network is a deep neural network that takes as input a vector of random noise and outputs a 28x28 grayscale image. The architecture of the generator consists of a fully connected layer followed by two convolutional transpose layers. The layers are activated using the LeakyReLU activation function and batch normalization is used to stabilize the training. The generator is trained to minimize the Wasserstein distance between the real and generated images.

The critic and generator networks are trained alternatively. In each iteration, the critic network is trained for a fixed number of iterations while the generator network is updated once. This process is repeated until convergence.

Acknowledgments

This code is adapted from the WGAN implementation in the book "Generative Deep Learning" by David Foster.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.