Dynamically Masked Discriminator for GANs

Wentian Zhang, Haozhe Liu, Bing Li, Jinheng Xie, Yawen Huang, Yuexiang Li, Yefeng Zheng, Bernard Ghanem

Abstract

Training Generative Adversarial Networks (GANs) is notoriously difficult, often characterized as a delicate "cat-and-mouse" game between the generator and the discriminator. Researchers have recently reimagined GAN training as an online continual learning problem, where the discriminator frequently struggles to keep pace with the generator's evolving output. By introducing a Dynamically Masked Discriminator (DMD) that detects its own "learning retardation" and forces itself to focus on new features via adaptive masking, researchers have achieved state-of-the-art image quality across multiple high-resolution benchmarks.

The Moving Target Problem

The standard view of GAN training involves the Generator (G) trying to fool the Discriminator (D), while D learns to distinguish real data from fake data. However, a subtle but critical flaw exists in this dynamic: the distribution of data produced by G is a moving target.

As G improves, the "fake" data it produces changes significantly over time. Standard discriminators often get "stuck" on historical features—patterns that were highly useful for identifying fakes early in training but are entirely irrelevant later on. This "retardation" in learning means D fails to provide G with the sharp, up-to-date feedback needed to reach high-fidelity results. Consequently, the generator is not penalized for new mistakes, often leading to persistent, localized artifacts in the generated images.

Example of persistent artifacts in generated images, highlighted by the red circle, which occur when the discriminator fixates on historical features.

Proposed Method: Dynamically Masked Discriminator

To address this, the authors propose the Dynamically Masked Discriminator (DMD), which treats GAN training as a continuous stream of data requiring rapid adaptation. The DMD framework consists of two primary mechanisms:

1. Retardation Detection

How does the discriminator know it is falling behind? Detecting learning stagnation without access to "future" data is challenging. The authors utilize a clever heuristic by creating "pseudo-samples"—randomly masking regions of a currently generated image.

They then compare the discriminator's internal feature maps for the original image against the masked version. If the feature maps are too similar (measured via high cosine similarity), it indicates that D is relying heavily on broad, historical knowledge. It is failing to notice the specific, local details and artifacts that G is currently producing.

Visualization of a discriminator's feature map, illustrating how it can fixate on specific regions and ignore new local details.

2. Dynamic Discriminator Adjustment

Once retardation is detected, the system intervenes to "kickstart" D's learning process. It applies a dynamic mask to D’s feature maps (or inputs) for a set interval. By actively hiding certain dominant features, D is forced to abandon its "old favorites" and must discover new, more relevant features to successfully distinguish real from fake.

Unlike standard Dropout, which is applied randomly and constantly throughout training, this masking is event-driven. It is triggered only when retardation is detected and persists just long enough to force a meaningful shift in the discriminator's attention, ensuring it remains a strict and evolving teacher for the generator.

Experimental Setup and Key Results

The DMD method was rigorously evaluated on several high-resolution and diverse benchmarks, including:

  • FFHQ: 70,000 high-quality human face images.
  • AFHQ-V2: Close-ups of animal faces (Cat, Dog, and Wild).
  • LSUN-Church: 120,000 images of outdoor churches.
  • CIFAR-10: A standard baseline for smaller-scale (32x32) generation.

The DMD consistently outperformed state-of-the-art (SOTA) baselines like StyleGAN-V2, StyleGAN-V3, and BigGAN across these datasets:

  • FFHQ: Reduced the FID (Fréchet Inception Distance, where lower is better) from 3.81 to 3.07 when combined with other augmentation techniques.
  • AFHQ-Cat: Achieved a massive 25.8% improvement in FID, dropping from 7.92 to 5.87.
  • LSUN-Church: Reached an FID of 3.06, significantly outperforming even advanced Latent Diffusion Models (LDM) which sat at 4.02.
  • Qualitative Quality: Images produced with DMD exhibit fewer "checkerboard" artifacts and boast much more realistic local textures, such as hair and skin pores, compared to standard StyleGAN-V2 outputs.

Key Insights

  1. GANs as Online Learning: Framing GAN training as online continual learning shifts the community's focus from mere "training stability" to "adaptation speed." This provides a fresh, actionable perspective on why GANs often plateau.
  2. The "Pseudo-Sample" Trick: Using masked versions of current samples as a proxy for a "new distribution" is a computationally cheap and highly effective way to measure the discriminator's sensitivity to change.
  3. Breaking Feature Dependency: Discriminators naturally develop "lazy" dependencies on specific local regions. Dynamically masking these regions breaks these habits, forcing continuous improvement.

Limitations and Future Work

While highly effective, the current study focused primarily on CNN-based GANs. Exploring how dynamic masking applies to Transformer-based discriminators (like those in ViT-GAN) is a necessary next step for the field. Additionally, while the heuristic for retardation detection works exceptionally well in practice, more rigorous theoretical studies could further solidify why this specific metric is the optimal trigger for masking. Finally, the depth of the layer where masking is applied and the ratio of the mask remain hyperparameters that require tuning, though initial probe studies suggest applying a 0.3 mask ratio at the 5th layer is generally effective.

Summary updated

BibTeX
@inproceedings{zhang2023dynamically,
  author = {Wentian Zhang and Haozhe Liu and Bing Li and Jinheng Xie and Yawen Huang and Yuexiang Li and Yefeng Zheng and Bernard Ghanem},
  title = {{Dynamically Masked Discriminator for GANs}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=sodl2c3aTM},
}
Figure