SMaRt: Improving GANs with Score Matching Regularity

Mengfei Xia, Yujun Shen, Ceyuan Yang, Ran Yi, Wenping Wang, Yong-Jin Liu

TL;DR

SMaRt (Score Matching Regularity) is a novel "plug-in" training strategy that fixes the notorious "gradient vanishing" problem in Generative Adversarial Networks (GANs). By leveraging pre-trained diffusion models as a guide, SMaRt provides a persistent gradient that pushes generated samples toward the real data manifold, significantly improving the synthesis quality of state-of-the-art GANs like StyleGAN2 and BigGAN.

What Problem Does This Paper Address?

Generative Adversarial Networks (GANs) are famous for their fast, high-quality image generation, but they are notoriously difficult to train. A primary reason is the gradient vanishing problem.

Mathematically, real-world data (like images of faces) resides on a low-dimensional "manifold" embedded in a high-dimensional pixel space. When a GAN starts training, its generated manifold and the real data manifold are often completely disjoint. In this scenario, a perfect discriminator can easily tell them apart, but it fails to provide any useful "direction" for the generator to move closer to the real data. The generator's loss becomes a non-optimal constant, its gradient effectively vanishes, and training stalls.

Figure 1. Motivation scheme of SMaRt. Red and blue surfaces denote the generated and real data manifolds, respectively. The positive-Lebesgue-measure subset of out-of-manifold generated samples leads to non-optimal constant generator loss, annihilating the gradient for generator. However, the proposed score matching regularity (Lscore in Eq. (10)) provides complementary guidance, urging such a subset to move towards the real data manifold. In this case, generator loss regains to exert effective guidance aiding the generator distribution to converge to the real distribution.

While previous works like WGAN attempted to solve this using different distance metrics (like Wasserstein distance), the authors of SMaRt argue that these are still insufficient for complex, highly diverse data.

Methods

The authors propose a hybrid approach: keep the adversarial framework of the GAN but add a Score Matching Regularity (SMaRt) term to the generator's loss function.

The core idea is to use a pre-trained Diffusion Probabilistic Model (DPM) as an "expert" that knows the shape of the data distribution. Diffusion models work by learning a "score function"—a vector field that points toward regions of high data density.

The SMaRt loss term ($\mathcal{L}_{score}$) essentially asks the generator: "If I add a little bit of noise to your output, can the pre-trained diffusion model successfully 'denoise' it back toward the real data manifold?"

Key technical components include:

  • Plug-in Regularity: SMaRt can be added to almost any existing GAN architecture without changing its internal structure.
  • Lazy Strategy: To save on the heavy computational cost of running a diffusion model, the regularity is only applied every few training steps (e.g., once every 8 iterations).
  • Narrowed Timestep Interval: Instead of using the full diffusion process, they only use a specific range of noise levels (timesteps) that provide the most effective guidance for refinement.

Datasets

The authors evaluated SMaRt across several standard benchmarks to prove its versatility:

  • CIFAR-10: A classic dataset of small 32x32 images.
  • ImageNet (64x64 and 128x128): A massive, diverse dataset used to test the model's ability to handle many different classes.
  • LSUN Bedroom (256x256): A common benchmark for high-resolution scene synthesis.

Key Insights and Ideas

  • The Lebesgue Measure Argument: The paper provides a rigorous theoretical proof (Theorems 3.1 and 3.2) showing that if the generated manifold has even a tiny "piece" (positive Lebesgue measure) outside the real manifold, the standard GAN loss fails to provide a gradient.
  • Score Matching as a Global Compass: Unlike a discriminator, which only gives feedback at the manifold boundaries, a score function provides a gradient field across the entire space. This ensures the generator always has a "compass" pointing toward the truth, even when it is far off-track.
  • Discrete vs. Continuous: In a striking toy example, the authors show that vanilla GANs struggle to capture discrete data points (like a grid of Gaussians), often "smearing" the results. SMaRt successfully forces the generator to land precisely on the discrete modes.
Figure 2. Visualization of discrete distribution example. The demonstrated toy data is simulated by a mixture of 49 2-dimensional Gaussian distributions with extremely low variance. Each data sample is a 2-dimensional feature tensor. Following Wang et al. (2022), we train a small GAN model, whose generator and discriminator are both parameterized by MLPs, with two 128-unit hidden layers and Leaky ReLU activation functions. We show (a) the true data samples, (b) the generated samples from vanilla GAN, (c) the generated samples from DiffusionGAN (Wang et al., 2022), and (d) the generated samples from our SMaRt. As is demonstrated, vanilla GAN and DiffusionGAN fail to address all samples onto the data manifold discretely, i.e., the generated samples tend to be continuous and out of the grids. As a comparison, our SMaRt can successfully synthesize discrete samples, whose distribution coincides with the ground-truth.

Key Results

SMaRt consistently improved the performance of various baseline GANs:

  • Aurora on ImageNet 64x64: Improved the Fréchet Inception Distance (FID)—a standard measure of image quality—from 8.87 to 7.11, putting it on par with more complex one-step consistency models.
  • StyleGAN2 on LSUN Bedroom: Reduced FID from 2.35 to 1.98.
  • BigGAN on ImageNet 128x128: Improved FID from 10.76 to 9.49.
  • Latent Space Continuity: Unlike some distilled diffusion models, GANs trained with SMaRt retain a "smooth" latent space, allowing for high-quality image interpolation (morphing one image into another smoothly).

Limitations and Future Work

While SMaRt is powerful, the authors note a few hurdles:

  • Hyperparameter Sensitivity: The effectiveness of the regularity depends on choosing the right weight ($\lambda_{score}$) and noise timesteps ($t$). Too much regularity can reduce the diversity of the generated images (mode collapse).
  • Computational Overhead: Even with the "lazy strategy," involving a large pre-trained diffusion model increases training time and memory usage.
  • Performance Gap: While SMaRt significantly narrows the gap, it does not yet outperform the very best (but much slower) multi-step diffusion models in terms of raw image fidelity.

The authors suggest that future research could explore using smaller, more efficient diffusion models as the "score expert" to further reduce training costs.

Summary updated

BibTeX
@inproceedings{xia2024smart,
  author = {Mengfei Xia and Yujun Shen and Ceyuan Yang and Ran Yi and Wenping Wang and Yong-Jin Liu},
  title = {{SMaRt: Improving GANs with Score Matching Regularity}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
  url = {https://openreview.net/forum?id=lqeVCc9zYq},
}
Figure