Self-Attention Generative Adversarial Networks

Han Zhang, Ian Goodfellow, Dimitris Metaxas, Augustus Odena

TL;DR

This paper introduces Self-Attention Generative Adversarial Networks (SAGANs), which leverage self-attention mechanisms to model long-range dependencies in image generation, overcoming limitations of traditional convolutional GANs. By integrating self-attention into both the generator and discriminator, and combining it with spectral normalization and a two-timescale update rule, SAGAN achieves state-of-the-art results on the ImageNet dataset, producing more coherent and detailed images.

What Problem Does This Paper Address?

Traditional Generative Adversarial Networks (GANs) built on convolutional architectures struggle to model long-range dependencies in images. Convolutional filters have a limited receptive field, meaning they only consider local information. To capture relationships between distant parts of an image, information must pass through many layers, which can be computationally inefficient and difficult for the network to learn effectively. This limitation is particularly evident in generating images with complex geometric or structural patterns, where details in one part of the image should be consistent with details far away. For instance, generating an animal with clearly defined limbs might be challenging if the network can only see a small patch at a time.

Methods

The core innovation is the introduction of a Self-Attention module into both the generator and discriminator of GANs. This module, inspired by self-attention mechanisms in natural language processing, allows each feature location to attend to all other feature locations, effectively modeling global dependencies.

Here's a breakdown of the key techniques:

  • Self-Attention Module: This module computes attention weights between feature maps. For a given feature location, it calculates a weighted sum of features from all locations, where the weights are determined by the similarity between features. This allows the network to dynamically focus on relevant information across the entire image, regardless of spatial distance.
  • Generator and Discriminator Integration: The self-attention module is applied to intermediate feature maps within both the generator (to inform detail generation) and the discriminator (to better assess global consistency).
  • Spectral Normalization (SN): To stabilize GAN training, the authors apply spectral normalization not only to the discriminator (as in prior work) but also to the generator. This constrains the Lipschitz constant of the weight matrices, preventing exploding gradients and improving training dynamics.
  • Two-Timescale Update Rule (TTUR): The paper advocates for using TTUR, which involves separate learning rates for the generator and discriminator. This is particularly beneficial for regularized discriminators that tend to learn slower, allowing for more efficient training.

Datasets

The primary dataset used for training and evaluation is ImageNet (LSVRC2012). The authors do not introduce any new benchmarks but focus on achieving state-of-the-art performance on this established, challenging dataset for class-conditional image generation.

Key Insights and Ideas

  • Self-Attention for Global Coherence: The most significant insight is that self-attention is a powerful tool for capturing long-range dependencies in images, leading to more globally coherent and structurally sound generated images. This directly addresses the limitations of local convolutional operations.
  • Attention to Object Shapes: Visualizations reveal that the self-attention mechanism learns to attend to regions that correspond to object shapes rather than fixed local areas. This suggests a more semantically aware generation process.
  • Generator Conditioning Matters: The paper reinforces the idea that generator conditioning is crucial for GAN performance. Applying spectral normalization to the generator, in addition to the discriminator, further stabilizes training and improves results.
  • Synergy of Stabilization Techniques: The combination of spectral normalization (on both G and D) and TTUR proves to be highly effective, leading to stable training with 1:1 update ratios and improved sample quality. The effects of these techniques are shown to be at least partly additive.

Key Results

  • State-of-the-Art Performance: SAGAN significantly outperforms previous state-of-the-art GAN models on the ImageNet dataset.
  • Inception Score (IS): Boosted from 36.8 to 52.52.
  • Fréchet Inception Distance (FID): Reduced from 27.62 to 18.65.
  • Intra FID: Achieved 83.7.
  • Improved Image Quality: Qualitative results show SAGAN generating images with better structural integrity and finer details, particularly for classes with complex patterns (e.g., animals with distinct limbs).
  • Stable Training: The proposed stabilization techniques (SN on G/D + TTUR) enable stable training with 1:1 generator-to-discriminator update ratios, which is desirable for faster convergence compared to the 5:1 ratios often required by prior methods.
  • Attention Module Effectiveness: Adding self-attention to middle-to-high level feature maps (e.g., 32x32 and 64x64) yields better results than applying it to low-level feature maps, indicating its strength in modeling larger-scale structures.

Limitations and Future Work

  • Computational Cost: While self-attention is computationally efficient for modeling long-range dependencies, it can still add computational overhead compared to pure convolutional networks, especially for very high-resolution images. The paper mentions reducing channel numbers for memory efficiency.
  • Dataset Specificity: The primary evaluation is on ImageNet. While impressive, it would be interesting to see how SAGAN performs on other diverse datasets or for different generation tasks (e.g., unconditional generation, image-to-image translation).
  • Future Work: The authors suggest that the self-attention mechanism can be further explored and integrated into other GAN architectures and tasks. The effectiveness of attention in modeling long-range dependencies opens doors for its application in various computer vision problems beyond image generation.

Summary updated

Abstract

In this paper, we propose the Self-Attention Generative Adversarial Network (SAGAN) which allows attention-driven, long-range dependency modeling for image generation tasks. Traditional convolutional GANs generate high-resolution details as a function of only spatially local points in lower-resolution feature maps. In SAGAN, details can be generated using cues from all feature locations. Moreover, the discriminator can check that highly detailed features in distant portions of the image are consistent with each other. Furthermore, recent work has shown that generator conditioning affects GAN performance. Leveraging this insight, we apply spectral normalization to the GAN generator and find that this improves training dynamics. The proposed SAGAN achieves the state-of-the-art results, boosting the best published Inception score from 36.8 to 52.52 and reducing Frechet Inception distance from 27.62 to 18.65 on the challenging ImageNet dataset. Visualization of the attention layers shows that the generator leverages neighborhoods that correspond to object shapes rather than local regions of fixed shape.
BibTeX
@inproceedings{zhang2019self,
  author = {Han Zhang and Ian Goodfellow and Dimitris Metaxas and Augustus Odena},
  title = {{Self-Attention Generative Adversarial Networks}},
  booktitle = {International Conference on Machine Learning},
  year = {2019},
  url = {https://openreview.net/forum?id=rJWFpjb_Wr},
}
Figure