Generalized Doubly Reparameterized Gradient Estimators

Matthias Bauer, Andriy Mnih

TL;DR

This paper introduces GDREGs, a powerful extension of the "doubly-reparameterized gradient" (DREGs) estimator. It allows researchers to slash gradient variance when training complex, hierarchical Variational Autoencoders (VAEs) and models with learnable priors, leading to faster convergence and better final model performance.

What Problem Does This Paper Address?

Training Variational Autoencoders (VAEs) requires calculating gradients of expectations—essentially figuring out how to tweak model parameters to maximize a "likelihood" objective. The standard tool for this is the Reparameterization Trick (RT), which yields low-variance "pathwise" gradients.

However, in more advanced objectives like the Importance Weighted Autoencoder (IWAE), the RT still leaves behind "score function" terms (similar to REINFORCE). These terms are notorious for high variance, which acts like "noise" that drowns out the learning signal, forcing researchers to use painfully small learning rates.

While a previous method called DREGs solved this for simple, single-layer VAEs, it had two major "blind spots":

  1. Hierarchical Models: It didn't account for the "indirect" score functions that crop up when you have multiple stochastic layers stacked on top of each other.
  2. Trainable Priors: It couldn't be applied to the parameters of the prior distribution ($p_\theta$), only the posterior ($q_\phi$).

Methods

The authors propose two main innovations to bridge these gaps:

  • Hierarchical DREGs: They demonstrate that in deep models, gradients that look like pathwise gradients actually contain hidden score function terms. They derive a consistent way to apply double reparameterization across multiple layers, effectively "cleaning" the gradient signal throughout the entire hierarchy.
  • Generalized DREGs (GDREGs): This is the core novelty. To handle the prior parameters, they use a clever "re-expression" trick. They take a sample already generated by the posterior and mathematically re-interpret it as if it had been sampled and reparameterized from the prior. This allows them to apply the DREGs logic to the prior's parameters, even though the prior wasn't the original sampling distribution.
The re-expression trick allows a sample from the posterior to be re-interpreted as if sampled from the prior.
  • Implementation via Surrogate Losses: To make these complex math identities usable in modern frameworks like PyTorch or JAX, the authors show how to implement them using "surrogate" loss functions. This allows standard automatic differentiation to handle the heavy lifting without manual gradient derivations.

Datasets

The researchers evaluated their estimators on three standard generative modeling benchmarks:

  • MNIST: Handwritten digits.
  • Omniglot: A "large-scale" alphabet dataset often used for few-shot learning.
  • FashionMNIST: Images of clothing items.

They tested these across both unconditional (generating images from scratch) and conditional (predicting the bottom half of an image given the top half) tasks.

Key Insights and Ideas

  • The "Indirect" Score Function: One of the most subtle insights is that in hierarchical models, the distribution parameters of one layer depend on the latent variables of the layer above. This dependency creates "indirect" score functions that standard reparameterization misses.
  • The Re-expression Flow: The visual representation of the re-expression flow is an "aha moment." It shows that you can change the "path" of a gradient (making it depend on the prior parameters $\theta$) without changing the numerical value of the sample itself.
  • SNR is the Metric that Matters: The paper focuses heavily on the Signal-to-Noise Ratio (SNR) of gradients. They show that while naive estimators see their SNR vanish as you add more importance samples ($K$), DREGs-based estimators actually see their SNR increase with $K$.
Gradient variance and SNR comparison showing GDREGs improving signal-to-noise ratio as importance samples increase.

Key Results

  • Variance Reduction: GDREGs consistently produced lower-variance gradients for the prior parameters compared to the standard IWAE estimator.
  • Better Performance: Models trained with (G)DREGs achieved higher test log-likelihoods (better generative quality) across almost all tested architectures and datasets.
  • Efficiency: The authors report that the computational overhead of using these more complex estimators is minimal—usually less than 10% increase in training time—making it a "low-cost, high-reward" upgrade.
  • Stability: The estimators performed particularly well in conditional modeling, where the prior and posterior are "closer" together, allowing the GDREGs identity to work most effectively.

Limitations and Future Work

  • Incomplete Elimination: For extremely complex model structures where the prior and posterior don't factorize in the same way, it is mathematically impossible to replace all indirect score functions with pathwise gradients.
  • Late-Training Variance: The authors noted that later in training, the gradient variance for the prior can sometimes increase. They hypothesize this is an indirect effect: because the posterior is learning so much better, the prior has a "harder" target to hit, leading to larger updates.
  • Normalizing Flows: The authors suggest that applying GDREGs to Normalizing Flows (a different class of generative models) is a promising next step, as these models rely heavily on complex coordinate transformations where pathwise gradients are essential.

Summary updated

BibTeX
@inproceedings{bauer2021generalized,
  author = {Matthias Bauer and Andriy Mnih},
  title = {{Generalized Doubly Reparameterized Gradient Estimators}},
  booktitle = {International Conference on Machine Learning},
  year = {2021},
}
Figure