Skip to content

mehalyna/MLDS_Sprint17_Task1_task

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sprint17. Generative AI in Data Science

Task 1. GAN for Image Generation using MNIST

Objective: This task is focused on building and training a Generative Adversarial Network (GAN) using the MNIST dataset to generate realistic handwritten digits. GANs consist of two networks — a Generator and a Discriminator — which compete against each other during the training process. The generator learns to create realistic-looking images, while the discriminator learns to differentiate between real and fake images.

Task Breakdown:

  1. Generator: The generator is responsible for taking random noise (latent vector) as input and transforming it into images resembling handwritten digits from the MNIST dataset.
  2. Discriminator: The discriminator takes an image as input and classifies it as real (from the dataset) or fake (generated by the generator).
  3. Adversarial Training: The GAN is trained in an adversarial manner. The generator tries to fool the discriminator, while the discriminator tries to accurately classify the images as real or fake.

Purpose:

  • The goal is to generate synthetic handwritten digits similar to those in the MNIST dataset.
  • The GAN will learn the data distribution of MNIST through iterative training.

Key Aspects of the Task:

  • Dataset: MNIST (handwritten digit images), with dimensions 28x28 pixels.
  • Generator Network: Takes a random noise vector as input and generates images.
  • Discriminator Network: Tries to distinguish between real images (from MNIST) and fake images (generated by the generator).
  • Loss Function: Binary cross-entropy (BCE) for both the generator and discriminator.
  • Optimization: Adam optimizer for both networks, with a learning rate of 0.0002.
  • Evaluation: The performance of the GAN is evaluated by the quality of generated images and the discriminator's ability to differentiate between real and fake images.

Solution:

The solution involves implementing both the generator and discriminator networks using PyTorch. The networks are then trained using an adversarial setup where the generator and discriminator improve together over epochs.

  1. Generator:
    • Takes a latent vector of size 64.
    • Passes it through multiple fully connected layers, applies ReLU activations, and outputs a 28x28 image (MNIST image size).
  2. Discriminator:
    • Takes an image (either real or generated) and passes it through fully connected layers, applying LeakyReLU activations.
    • Outputs a probability (real or fake classification).
  3. Training:
    • In each iteration, the discriminator is updated first by using both real images and fake images generated by the generator. Then, the generator is updated to fool the discriminator by generating more realistic images.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages