Self-Attention GAN

The paper inserted self-attention into GANs so image generation could model long-range spatial dependencies.

Metadata

FieldValue
PaperSelf-Attention Generative Adversarial Networks
AuthorsHan Zhang, Ian Goodfellow, Dimitris Metaxas, Augustus Odena
Year2019
VenueICML 2019
PMLRvolume 97 paper
arXiv1805.08318
Statusverified

Question

Convolutional GANs such as DCGAN build images through local receptive fields. This is efficient, but a far-away region may only influence another region after many layers.

SAGAN asks:

The answer is to add self-attention to the generator and discriminator.

Main Claim

Self-Attention GAN adds non-local attention blocks to image GANs:

The durable architecture claim is:

This is an architecture paper because it changes how the generator and discriminator exchange information across image locations.

Architecture Contract

ItemContract
Inputimage feature map
Attention axisspatial positions
Query/key/valuelearned projections of feature maps
Outputattention-weighted feature map added residually
Placementgenerator and discriminator feature hierarchy
Stabilizationspectral normalization
Main biaslong-range dependency modeling for image synthesis

Self-Attention Block

Flatten the spatial grid:

Compute projections:

The attention matrix is:

The attended feature is:

The block returns a residual mixture:

where is a learned scalar initialized so the network can start close to the convolutional baseline.

Why Attention Helps Images

Convolutions are local:

Self-attention lets a position read from all positions:

This matters when global consistency is important:

Visual NeedWhy Local Convolution Can Struggle
object shape consistencydistant parts must agree
repeated structuresseparated regions share pattern
scene layoutglobal relations affect local detail
fine detail conditioned on far contextlocal receptive field may be insufficient

Spectral Normalization

SAGAN also uses spectral normalization to stabilize GAN training. For a weight matrix :

where is the largest singular value.

This controls the Lipschitz behavior of layers:

In SAGAN, spectral normalization is part of the practical architecture recipe, especially for the discriminator.

Relation to Transformer Attention

SAGAN attention is not a full Transformer block. It is a non-local spatial block inserted inside a convolutional GAN.

ModelAttention Role
Transformerprimary sequence modeling operator
SAGANglobal spatial feature mixing inside GAN
DiTprimary denoising backbone over latent patches

The shared mechanism is query-key-value attention; the surrounding architecture is different.

Evidence

Evidence TypeWhat It Supports
ImageNet image generationattention improves image quality in class-conditional GANs
attention mapsgenerated details can depend on distant regions
ablation with attentiongains are tied to adding non-local blocks
spectral normalization usestabilizes adversarial training in the reported setup

Limits

  • Full spatial attention costs over feature-map positions.
  • The result depends on GAN training details, normalization, and conditioning.
  • Attention does not remove adversarial training instability.
  • Later diffusion and Transformer generators changed the dominant high-resolution generation landscape.

Concepts