Generative Adversarial Networks (GANs)
Generative Adversarial Networks (GANs)
GAN stands for Generative Adversarial Network. It is basically two AI models fighting each other, and that fight is what makes both of them smarter.
A GAN has two parts. The generator creates fake data, and the discriminator tries to tell real data apart from fake. Every time the discriminator catches a fake, the generator learns from that and tries again, a little better this time. Round after round, the generator gets so good that even the expert struggles to spot the fake.
It generates things like images of dogs or landscapes starting from random noise, and over time those random pixels start looking like real photos.
Generator vs Discriminator
Generator | Discriminator |
| Takes random noise as input. | Takes real and generated data as input. |
| Generates fake samples, such as faces or objects. | Determines whether the input is real (1) or fake (0). |
| Learns to create increasingly realistic outputs. | Learns from real data to recognize authentic features. |
| Improves through feedback from the discriminator. | Provides feedback that helps the generator improve. |
| Its goal is to fool the discriminator. | Its goal is to correctly distinguish real data from generated data. |
How GANs Are Trained
Step 1: Generate Fake Samples
First, the generator creates a batch of fake samples from random noise.
Step 2: Evaluate the Samples
Next, the fake samples are mixed with real samples and passed to the discriminator, which predicts whether each sample is real or fake.
Step 3: Calculate the Generator's Error
Then, the generator's error is calculated by comparing the discriminator's prediction with the generator's goal of making the fake samples appear real.
Step 4: Update the Generator
After that, the generator adjusts its weights using backpropagation to produce more realistic samples.
Step 5: Repeat the Process
Finally, the generator and discriminator continue training together over many iterations, gradually improving until the generated data becomes difficult to distinguish from real data.
Types of GANs and Their Uses
Once GANs took off, people started customizing them for specific jobs:
- Conditional GANs (CGAN): A label gets fed in alongside the noise, so instead of generating something totally random, you can ask for a specific category, like a dog instead of leaving it to chance
- Deep Convolutional GANs (DCGAN): This swaps in convolutional layers and drops fully connected ones, giving it much better grip on spatial detail in images, which is why it is the go-to choice for generating realistic faces or objects
- Laplacian Pyramid GANs (LAPGAN): Uses multiple generator and discriminator pairs at different resolution levels, which helps it produce especially high quality, high resolution images










