AI Model Wiki

    Skip to main content
    Back to Glossary

    GAN (Generative Adversarial Network)

    A Generative Adversarial Network is a framework in which two neural networks — a generator and a discriminator — are trained simultaneously in opposition. The generator's job is to produce synthetic data (images, audio, text) that resembles real training samples; the discriminator's job is to classify inputs as real or fake. Each network improves by trying to outpace the other: the generator learns to fool the discriminator, and the discriminator learns to catch better fakes. At convergence, the generator can produce outputs that are statistically indistinguishable from real data. Ian Goodfellow introduced GANs in 2014.

    Think of it like a counterfeiter and a detective locked in an escalating arms race. The counterfeiter (generator) keeps refining fake banknotes; the detective (discriminator) keeps developing better tests. Neither can stop improving because the other's improvement raises the bar — and after enough iterations, the fakes become almost perfect.

    Training a simple GAN in PyTorch follows a two-phase loop per batch:

    # Phase 1: train discriminator on real + fake
    real_loss = criterion(D(real_images), ones)
    fake_loss = criterion(D(G(noise).detach()), zeros)
    d_loss = real_loss + fake_loss; d_loss.backward()
    
    # Phase 2: train generator to fool discriminator
    g_loss = criterion(D(G(noise)), ones)  # wants D to say "real"
    g_loss.backward()
    

    GANs are closely related to Latent Space (the noise vector the generator samples from), Diffusion (the dominant successor for image synthesis), Loss Function (the adversarial objective is a minimax game), and Generative AI as the broader category they helped define. Mode collapse — where the generator produces limited variety — was a longstanding training challenge that diffusion models largely sidestep.

    You will encounter GANs in older image synthesis literature, super-resolution pipelines, data augmentation tools, and anywhere synthetic training data needs to be generated efficiently without the sampling overhead of diffusion.

    AI Terminology
    Glossary