Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Principle:Zai org CogVideo PatchGAN Discriminator

From Leeroopedia


Knowledge Sources
Domains Generative_Adversarial_Networks, Image_Synthesis
Last Updated 2026-02-10 00:00 GMT

Overview

A PatchGAN discriminator classifies overlapping local patches of an image as real or fake rather than making a single global decision, encouraging the generator to produce sharp, realistic textures at fine spatial scales.

Description

Traditional GAN discriminators produce a single scalar output for the entire image, which captures global structure but provides limited gradient signal for local texture quality. The PatchGAN discriminator instead outputs a spatial map where each element corresponds to a receptive field (patch) of the input image. Each patch is independently classified as real or fake, and the overall discriminator loss is the average over all patches.

The architecture is a fully convolutional network with no fully connected layers, consisting of:

  • A series of strided convolutional layers (typically 4x4 kernels with stride 2) that progressively downsample the input
  • Normalization (BatchNorm or alternatives like ActNorm) and LeakyReLU activations after each convolution
  • A final convolutional layer that maps to a single-channel output

The effective receptive field size determines the "patch" that each output element evaluates. With the standard configuration (3 downsampling layers, 4x4 kernels), the receptive field is 70x70 pixels, which has been shown to produce a good balance between capturing local texture and maintaining some structural awareness.

Usage

Use a PatchGAN discriminator when training generative models that must produce sharp, locally coherent textures. It is particularly effective for:

  • Image-to-image translation tasks
  • Autoencoder training where reconstruction sharpness is important
  • Any GAN setup where local texture quality matters more than global layout

Theoretical Basis

The PatchGAN discriminator can be viewed as a form of texture/style loss. Let D be the discriminator and D(x)i,j be its output at spatial position (i,j). The adversarial loss is:

adv=𝔼xpdata[1Ni,j(D(x)i,j,1)]+𝔼xpG[1Ni,j(D(x)i,j,0)]

where is a per-element loss (e.g., cross-entropy or hinge loss) and N is the number of spatial positions.

Each output element D(x)i,j has a receptive field R determined by the network architecture. For a network with L layers of kernel size k and stride s:

R=1+l=1L(kl1)m=1l1sm

The spatial averaging of per-patch losses means that the generator receives dense gradient feedback for every local region of the output, rather than a single gradient for the entire image. This encourages uniform local quality across the generated image and has been shown empirically to produce results comparable to full-image discriminators for high-frequency (texture) quality, while being more parameter-efficient and stable to train.

The fully convolutional design also means the discriminator can accept inputs of any spatial resolution without architectural changes, making it flexible for variable-resolution training.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment