Skip to main content
QUICK REVIEW

[Paper Review] Dual Contrastive Loss and Attention for GANs

Ning Yu, Guilin Liu|arXiv (Cornell University)|Mar 31, 2021
Generative Adversarial Networks and Image SynthesisComputer Science100 references5 citations
TL;DR

This paper proposes a dual contrastive loss and attention mechanisms to improve GAN-based image generation, significantly enhancing feature representation and long-range modeling. By combining a novel contrastive loss with self-attention in the generator and reference-attention in the discriminator, the method achieves at least a 17.5% improvement in FID on benchmark datasets and up to 47.5% on compositional scenes like CLEVR, setting a new state of the art in image quality and realism.

ABSTRACT

Generative Adversarial Networks (GANs) produce impressive results on unconditional image generation when powered with large-scale image datasets. Yet generated images are still easy to spot especially on datasets with high variance (e.g. bedroom, church). In this paper, we propose various improvements to further push the boundaries in image generation. Specifically, we propose a novel dual contrastive loss and show that, with this loss, discriminator learns more generalized and distinguishable representations to incentivize generation. In addition, we revisit attention and extensively experiment with different attention blocks in the generator. We find attention to be still an important module for successful image generation even though it was not used in the recent state-of-the-art models. Lastly, we study different attention architectures in the discriminator, and propose a reference attention mechanism. By combining the strengths of these remedies, we improve the compelling state-of-the-art Fréchet Inception Distance (FID) by at least 17.5% on several benchmark datasets. We obtain even more significant improvements on compositional synthetic scenes (up to 47.5% in FID). Code and models are available at https://github.com/ningyu1991/AttentionDualContrastGAN .

Motivation & Objective

  • To address the persistent issue of generated images being easily detectable despite state-of-the-art GAN performance.
  • To improve discriminator generalization and representation learning to reduce mode collapse and improve generation quality.
  • To re-evaluate the role of attention in modern GANs, especially after its omission in recent SOTA models like StyleGAN2.
  • To design a novel reference-attention mechanism in the discriminator that leverages real images as references to stabilize training on limited datasets.
  • To demonstrate that contrastive learning can synergize with attention to produce superior, more robust generative models.

Proposed method

  • Introduce a dual contrastive loss that replaces the standard adversarial loss, encouraging the discriminator to learn more generalized and distinguishable representations between real and fake samples.
  • Integrate self-attention modules into the generator to model long-range dependencies across image regions, improving structural coherence and detail generation.
  • Propose a reference-attention mechanism in the discriminator, where two Siamese branches process a real reference image and a primary image (real or generated), with attention guided by the real image to reduce overfitting.
  • Use a contrastive learning framework that compares positive and negative pairs of real and fake features, enhancing discriminative power and feature diversity.
  • Train the GAN using a minimax objective with the dual contrastive loss, enabling better gradient signals to the generator.
  • Combine the dual contrastive loss with self-attention in the generator and reference-attention in the discriminator to achieve synergistic improvements in image quality.

Experimental results

Research questions

  • RQ1Does a dual contrastive loss improve discriminator generalization and lead to better image generation quality compared to standard GAN losses?
  • RQ2Can attention mechanisms still enhance GAN performance in the absence of their use in recent SOTA models like StyleGAN2?
  • RQ3How does the choice of attention mechanism affect generator and discriminator performance across different datasets and data scales?
  • RQ4Does the proposed reference-attention mechanism in the discriminator improve generalization, especially on limited-scale datasets?
  • RQ5What is the combined effect of contrastive learning and attention on image generation quality, particularly on complex, compositional scenes like CLEVR?

Key findings

  • The dual contrastive loss reduces FID by up to 37% on the CLEVR dataset, demonstrating significant improvement in generalization and representation learning.
  • The combination of self-attention in the generator and dual contrastive loss achieves at least a 17.5% relative improvement in FID across multiple large-scale datasets.
  • On the CLEVR dataset, the method reduces artifacts such as color leakage, discontinuities, and structural errors, particularly in scenes with occlusions, shadows, and reflections.
  • The reference-attention discriminator improves performance on limited-scale datasets by leveraging real reference images to guide attention and reduce overfitting.
  • The self-attention generator improves FID by up to 13.3% on the Bedroom dataset, highlighting its benefit for complex, high-variance scenes.
  • On the FFHQ dataset, self-attention does not improve performance, likely due to facial landmark alignment compensating for local inductive bias, suggesting context-dependent benefits of attention.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.