PERSON 3: Discriminator & Stage-II (4 Minutes)
SLIDE 6: Stage-I Discriminator
"Thanks. Now let's look at the critic—the Stage-I Discriminator.
While the Generator creates, the Discriminator judges. It starts with an image encoder taking
the 64x64 input. We use standard Conv2d layers with LeakyReLU to progressively
downsample the image from 64x64 down to 4x4, increasing the channel depth to 512.
Crucially, this discriminator doesn't just look at the image; it reads the text.
We take the 128-dimensional text embedding and replicate it spatially to match the image
features (4x4). We concatenate them—image features plus text features—and use a final
convolution to produce a single scalar output.
This output answers: 'Is this image real AND does it match the text?'
To teach it this distinction, we train on three specific pairs:
1. Real + Matching text: Label is 1.
2. Fake + Text: The generated image. Label is 0.
3. Real + Mismatching text: A real image paired with a random wrong description. Label is
0.
This third pair is vital—it forces the model to actually understand semantic consistency, not
just image quality."
SLIDE 7: Stage-II Generator
"Moving to Stage-II, this is where we refine the 64x64 sketch into a 256x256 photo-realistic
image.
The Stage-II Generator first encodes the output from Stage-I, compressing it back down to
extract structural features.
We apply Conditioning Augmentation to the text again. Note that while we use the same text
embedding, we sample a new random noise code. This allows Stage-II to add its own
variations while staying consistent with the description.
The major architectural difference here is the use of Residual Blocks. We use four of them.
Instead of generating from scratch, these blocks allow the model to learn incremental
refinements—adding texture and lighting details without destroying the structure created in
Stage-I.
Finally, we pass this through four upsampling steps, doubling resolution each time until we
reach the final 256x256 RGB output.
The Stage-II Discriminator follows the same logic as Stage-I but operates on this higher
resolution."
SLIDE 8: Training Loop - Stage-I
"Finally, let's look at the implementation of the Training Loop.
We initialize both networks using the Adam optimizer with a learning rate of 0.0002 (2e-4)
and betas 0.5 and 0.999—standard hyperparameters for stable GAN training.
Inside the epoch loop, we update the networks in two steps:
Step 1: The Discriminator.
We calculate three distinct losses:
1. errD_real: Loss on real images with right text.
2. errD_fake: Loss on generated images.
3. errD_mismatch: Loss on real images with wrong text.
We average the fake and mismatch losses to balance the gradients so real data isn't
overwhelmed.
Step 2: The Generator.
We update G based on the adversarial loss (trying to fool D) plus the KL Divergence loss. We
weight the KL loss by 2.0 to ensure the text conditioning remains smooth and meaningful.
We run this minimax game for 600 epochs, saving checkpoints every 50. Now, Person 4 will
dive deeper into the specific loss functions."