Hitesh Sahu
Hitesh SahuHitesh Sahu
  1. Home
  2. ›
  3. posts
  4. ›
  5. …

  6. ›
  7. 5 0 GAN

Loading ⏳
Fetching content, this won’t take long…


💡 Did you know?

🍯 Honey never spoils — archaeologists found 3,000-year-old jars still edible.

🍪 This website uses cookies

No personal data is stored on our servers however third party tools Google Analytics cookies to measure traffic and improve your website experience. Learn more

Loading ⏳
Fetching content, this won’t take long…


💡 Did you know?

🤯 Your stomach gets a new lining every 3–4 days.
Cover Image for Generative Adversarial Networks (GANs) Explained

Generative Adversarial Networks (GANs) Explained

Learn how Generative Adversarial Networks (GANs) work, including generators, discriminators, adversarial training, minimax optimization, image synthesis, and modern generative AI applications.

Hitesh Sahu
Written by Hitesh Sahu, a passionate developer and blogger.

Tue May 26 2026

Share This on

← Previous

kubernetes Index

Next →

U-Net Explained

Generative Adversarial Network (GAN)

Deep learning architecture where two neural networks compete against each other to generate realistic synthetic data.

-Introduced by Ian Goodfellow in 2014.

A GAN is a neural network system where:

  • one model generates fake data,
  • another model detects fake data,
  • and both improve through adversarial competition.

Popular GAN Variants

Variant Purpose
DCGAN CNN-based GAN
CycleGAN Image translation
StyleGAN High-quality face generation
Conditional GAN Controlled generation
Wasserstein GAN (WGAN) Stable training

GANs in the Generative AI Landscape

  • GAN models are known for potentially unstable training and less diversity in generation due to their adversarial training nature.
  • VAE relies on a surrogate loss.
  • Flow models have to use specialized architectures to construct reversible transform.
  • Diffusion models are more stable and produce higher quality outputs, but are slower to generate content.

GAN vs Diffusion Models

GAN Diffusion Models
Faster generation Slower generation
Harder training More stable
Sharp outputs Better diversity
More instability Higher realism

Applications of GANs

  1. Image Generation
    • Human faces
    • Art
    • Landscapes
    • Avatars
  2. Deepfakes
    • AI Art
  3. Super Resolution: Improve image resolution and quality.
  4. Image-to-Image Translation
    • Sketch → Photo
    • Day → Night
    • Black & White → Color
  5. Data Augmentation: Generate synthetic training datasets.

GAN Architecture

flowchart TD

    A[Random Noise z] --> B[Generator]

    B --> C[Generated Fake Image]

    C --> D[Discriminator]

    E[Real Image Dataset] --> D

    D --> F{Real or Fake?}

    F -->|Real| G[Correct Classification]

    F -->|Fake| H[Generator Improves]

GAN Architecture

Core Components

Component Role
Generator Creates fake/generated data
Discriminator Detects whether data is real or fake

Generator Objective

Generator = Counterfeit Artist

Example: The artist improves fake currency generation.

The Generator tries to create realistic synthetic data.

G(z)→xfakeG(z) \rightarrow x_{fake}G(z)→xfake​

Where:

  • zzz = Random latent vector
  • xfakex_{fake}xfake​ = Generated fake sample

Discriminator Objective

Discriminator = Police Detective

Example: The detective improves fake detection.

The Discriminator classifies whether data is real or fake.

D(x)∈[0,1]D(x) \in [0,1]D(x)∈[0,1]

Where:

  • 000 = Fake
  • 111 = Real

GAN Minimax Objective Function

GAN training is a minimax optimization problem.

min⁡Gmax⁡DV(D,G)=Ex∼pdata(x)[log⁡D(x)]+Ez∼pz(z)[log⁡(1−D(G(z)))]\min_G \max_D V(D,G)= \mathbb{E}_{x \sim p_{data}(x)}[\log D(x)]+ \mathbb{E}_{z \sim p_z(z)}[\log(1 - D(G(z)))]Gmin​Dmax​V(D,G)=Ex∼pdata​(x)​[logD(x)]+Ez∼pz​(z)​[log(1−D(G(z)))]

Where:

  • GGG = Generator
  • DDD = Discriminator
  • xxx = Real data sample
  • zzz = Random noise vector
  • pdatap_{data}pdata​ = Real data distribution
  • pzp_zpz​ = Noise distribution

GAN Training Flow

GAN Training Flow

sequenceDiagram

    participant Z as Random Noise
    participant G as Generator
    participant D as Discriminator

    Z->>G: Generate Fake Sample

    G->>D: Fake Image

    D->>D: Predict Fake

    Note over D: Train Discriminator

    D-->>G: Feedback / Gradient

    Note over G: Improve Generator

Step 1: Train Discriminator

  • Feed real images
  • Feed fake/generated images
  • Learn classification

Step 2: Train Generator

  • Generate fake images
  • Try to fool discriminator

Step 3: Repeat Iteratively

Both networks improve over time.

flowchart LR

    G[Generator] -->|Creates Fake Data| D[Discriminator]

    D -->|Detects Fake Data| G

    G -->|Improves Realism| D

    D -->|Improves Detection| G

Challenges in GANs

  1. Mode Collapse : Generator produces limited variety.
  2. Training Instability: GANs are difficult to balance and optimize.
  3. Vanishing Gradients : Discriminator becomes too strong.
  4. Evaluation Difficulty: Generated quality is hard to measure objectively.
← Previous

kubernetes Index

Next →

U-Net Explained

AI-GenAI/5-0-GAN
Let's work together
+49 176-2019-2523
hiteshkrsahu@gmail.com
WhatsApp
Skype
Munich 🥨, Germany 🇩🇪, EU
Playstore
Hitesh Sahu's apps on Google Play Store
Need Help?
Let's Connect
Navigation
  Home/About
  Skills
  Work/Projects
  Lab/Experiments
  Contribution
  Awards
  Art/Sketches
  Thoughts
  Contact
Links
  Sitemap
  Legal Notice
  Privacy Policy

Made with

NextJS logo

NextJS by

hitesh Sahu

| © 2026 All rights reserved.