gendigit / README.md
marlonsousa's picture
Upload README.md
2d16da1 verified

A newer version of the Gradio SDK is available: 6.13.0

Upgrade
metadata
title: Gendigit
emoji: πŸš€
colorFrom: yellow
colorTo: green
sdk: gradio
sdk_version: 5.17.1
app_file: app.py
pinned: false
license: mit
short_description: 'This project implements a Generative Adversarial Network '

GenDigit

This project implements a Generative Adversarial Network (GAN) that generates images of handwritten digits using the MNIST dataset. The network consists of two primary components:

  • Generator (G): A neural network that generates fake images based on random noise and the desired label (digit).
  • Discriminator (D): A neural network that evaluates whether an image is real (from the dataset) or fake (generated by the generator).

Generator (G) Loss Function:

The Generator tries to minimize the binary cross-entropy loss by generating images that fool the Discriminator. The loss for the Generator is:

LG=βˆ’Ez[log⁑D(G(z))] L_G = -\mathbb{E}_{z}[ \log D(G(z)) ]

Where:

  • $$ z $$ is the random noise input to the Generator.
  • $$ G(z) $$ is the generated image.
  • $$ D(G(z)) $$ is the Discriminator's probability that the generated image is real.

The Generator is trained to minimize this loss by improving its ability to generate realistic images.

Discriminator (D) Loss Function:

The Discriminator tries to distinguish between real and fake images. Its loss consists of two parts:

  1. Loss for real images: $$ L_{D_{\text{real}}} = -\mathbb{E}{x{\text{real}}}[ \log D(x_{\text{real}}) ] $$
  2. Loss for fake images: $$ L_{D_{\text{fake}}} = -\mathbb{E}_{z}[ \log (1 - D(G(z))) ] $$

Where:

  • $$ x_{\text{real}} $$ is a real image from the dataset.
  • $$ D(x_{\text{real}}) $$ is the Discriminator's prediction for a real image.
  • $$ G(z) $$ is the fake image generated by the Generator.

The total loss for the Discriminator is:

LD=LDreal+LDfake L_D = L_{D_{\text{real}}} + L_{D_{\text{fake}}}

The Discriminator is trained to minimize this loss by improving its ability to classify real and fake images correctly.