liveBook · Manning

Adversarial loss

As explained in Build a Text-to-Image Generator (from Scratch)

An adversarial loss is a training objective that evaluates how convincingly generated samples resemble real samples in a generative adversarial setup.

Adversarial loss is a training objective that rewards generated images for looking convincingly real. In VQGAN, a discriminator evaluates decoded images as real or fake while the generator learns to fool it. section 11.4.2

VQGAN combines adversarial loss with reconstruction or perceptual loss and quantization loss. These objectives divide the work: adversarial loss promotes perceptual realism, perceptual loss preserves visual similarity, and quantization loss keeps encoder outputs close to codebook vectors. section 11.6 section 11.4.2

Trace the adversarial mechanism through the VQGAN pipeline:

  • The VQ-VAE generator encodes an image, quantizes its latent representation into discrete codes, and decodes those codes into a reconstruction. section 11.0
  • The discriminator compares real training images with generated reconstructions and learns to distinguish real samples from fake ones. section 11.4.2
  • The generator receives adversarial pressure to produce decoded images that can fool the discriminator and appear perceptually convincing. section 11.4.2

VQGAN reconstruction

A VQGAN decodes discrete codebook vectors into an image. Reconstruction and perceptual objectives keep it visually similar to the input, while adversarial loss pushes the result toward the appearance of a realistic training sample. section 11.4.2

Figure 11.6 VQGAN architecture and training process in which VQGAN combines a VQ-VAE generator with a discriminator in a GAN framework
A diagram of a fish

AI-generated content may be incorrect.

Use the architecture figure to follow how the VQ-VAE generator and discriminator interact during adversarial training. section 11.4.2

How Build a Text-to-Image Generator (from Scratch) covers it

How deep it goes
Explains the discriminator interaction and weighted loss role without specifying an optimization formula.
Examples
Uses VQGAN reconstructions, real-versus-fake discriminator judgments, and LPIPS-based perceptual comparison.
What it assumes
Assumes GAN and VQ-VAE foundations while introducing their combination through VQGAN.
What you can do after
Evaluate/understand how adversarial training improves the perceptual realism of VQGAN reconstructions.
How it connects
Connects GANs, discriminators, VQ-VAEs, perceptual loss, quantization loss, LPIPS, and VQGAN.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build a Text-to-Image Generator (from Scratch). The section links point to the parts of the book it draws on.