0
0
PyTorchml~12 mins

Generator and discriminator in PyTorch - Model Pipeline Trace

Choose your learning style9 modes available
Model Pipeline - Generator and discriminator

This pipeline shows how a generator and discriminator work together in a GAN (Generative Adversarial Network). The generator creates fake images, and the discriminator learns to tell real images from fake ones. They improve by competing with each other.

Data Flow - 4 Stages
1Input noise vector
64 rows x 100 columnsRandom noise sampled from a normal distribution64 rows x 100 columns
[0.12, -0.45, 0.33, ..., 0.05]
2Generator network
64 rows x 100 columnsTransforms noise into fake images using layers of neural network64 rows x 1 x 28 x 28
Tensor of pixel values between -1 and 1 representing fake images
3Real images input
64 rows x 1 x 28 x 28Batch of real images from dataset64 rows x 1 x 28 x 28
Tensor of pixel values between -1 and 1 representing real images
4Discriminator network
64 rows x 1 x 28 x 28Classifies images as real or fake64 rows x 1
[0.9, 0.1, 0.8, ..., 0.05] (probabilities of being real)
Training Trace - Epoch by Epoch
Loss
1.2 |****
0.9 |***
0.7 |**
0.5 |*
0.4 |
EpochLoss ↓Accuracy ↑Observation
11.20.55Loss is high, accuracy near random guessing
20.90.65Loss decreased, discriminator starts to learn
30.70.75Generator improves, discriminator accuracy increases
40.50.82Loss continues to decrease, model converging
50.40.88Good balance between generator and discriminator
Prediction Trace - 3 Layers
Layer 1: Input noise vector
Layer 2: Generator network
Layer 3: Discriminator network
Model Quiz - 3 Questions
Test your understanding
What is the role of the generator in this pipeline?
AClassify images as real or fake
BCreate fake images from noise
CProvide real images from dataset
DCalculate loss function
Key Insight
The generator and discriminator improve together by competing. The generator learns to create more realistic images, while the discriminator gets better at spotting fakes. This balance helps the GAN produce convincing fake images over time.