On the Value of Infinite Gradients in Variational Autoencoder Models

Bin Dai, Wenliang Li, David P. Wipf

While "exploding gradients" are usually treated as a bug to be fixed in deep learning, this paper argues they are actually a vital feature for Variational Autoencoders (VAEs). The authors prove that infinite gradients are mathematically necessary to achieve "optimal sparse representations"—the state where a model perfectly reconstructs data using the minimum number of latent dimensions. Furthermore, they show that learning the decoder variance acts as a crucial smoothing mechanism to navigate this unstable optimization landscape.

The Problem: Bounded Gradients vs. Manifold Learning

Training continuous VAEs often leads to a frustrating phenomenon: as the model improves, certain parameter gradients drift toward infinity. This typically happens when the decoder's noise parameter ($\gamma$) approaches zero. Historically, researchers have viewed this as a numerical instability to be avoided through heuristic constraints or modified energy functions.

However, the authors ask a fundamental question: What do we lose by forcing gradients to stay bounded?

They specifically examine data that lies on a low-dimensional manifold. For example, natural images have thousands of pixels but far fewer "true" degrees of freedom. The challenge in VAE training is finding a model that is neither "over-regularized" (suffering from posterior collapse where it ignores the latent space) nor "under-regularized" (where it uses more latent dimensions than necessary, leading to blurry samples).

Data lying on a low-dimensional manifold within a higher-dimensional ambient space.

The Necessity of Infinite Gradients

The paper combines rigorous mathematical proofs with empirical simulations to establish a theoretical framework around "Optimal Sparse (Lossless) Representations." This is defined as a state where reconstruction error is zero and the number of active latent dimensions is minimized.

The core of the paper is Theorem 4. It proves that for a broad class of autoencoder objectives, if the penalty functions have bounded gradients, the model cannot guarantee an optimal sparse representation across all datasets.

In short: if you want perfect sparsity to prune unnecessary latent dimensions, the model needs a "sharp" penalty at zero. This sharpness is exactly what causes the infinite gradients. If you flatten that penalty to keep gradients bounded, the model loses its ability to find the most parsimonious representation.

Candidate decoders and the sharp penalty function required for optimal sparsity.

The Smoothing Curriculum of Decoder Variance

If infinite gradients are necessary, how do VAEs ever converge? The authors analyze the role of the trainable decoder variance ($\gamma$).

They argue that treating $\gamma$ as a learnable parameter—rather than a fixed constant—creates an automated "smoothing" curriculum. Early in training, $\gamma$ is large, making the loss surface smooth, convex-like, and easy to navigate. As the model converges, $\gamma$ shrinks, "localizing" the infinite gradients to the very end of the optimization process. This explains why VAEs often succeed despite the theoretical presence of "bad" local minima.

Additionally, the authors point out a conflict in $\beta$-VAEs: if $\beta$ is set too high (specifically $\beta > d/r$, where $d$ is data dimension and $r$ is manifold dimension), the model will actually sacrifice reconstruction accuracy, making optimal sparse representations impossible to reach.

Key Findings and Empirical Results

The authors validate their theory using synthetic manifold data, CelebA, and MNIST variants:

  • Empirical Stability: In experiments on CelebA, fixing $\gamma$ to its "optimal" tiny value from the start leads to massive initial gradients that disrupt training. Conversely, learning $\gamma$ starts with small gradients and leads to a much better final latent distribution (measured by Maximum Mean Discrepancy, or MMD).
  • Sparsity vs. Quality: Achieving these sparse representations is shown to be a necessary condition for generating high-quality, non-blurry samples that truly match the training distribution.
  • Outlier Detection: A model capable of reaching an optimal sparse representation is significantly better at "screening" outliers. Because it has squeezed the latent space down to only what is necessary for the "inlier" data, outliers are much easier to identify.

Limitations and Future Work

While the paper focuses on the "under-regularization" end of the spectrum (using too many active dimensions), the authors acknowledge that learning $\gamma$ isn't a panacea. If $\gamma$ stays too high for too long, the model can still fall into posterior collapse.

Crucially, while the paper argues we should accommodate large gradients, it doesn't provide a new "silver bullet" optimizer. It suggests standard stability measures—like reducing step sizes or gradient clipping—are the right path, rather than changing the fundamental VAE objective itself to artificially bound gradients. Finally, they note that even more flexible VAEs (with non-Gaussian posteriors or trainable priors) still face these same fundamental trade-offs regarding infinite gradients.

Summary updated

BibTeX
@inproceedings{dai2021value,
  author = {Bin Dai and Wenliang Li and David P. Wipf},
  title = {{On the Value of Infinite Gradients in Variational Autoencoder Models}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2021},
}
Figure