Langevin Dynamics with Continuous Tempering for Training Deep Neural Networks

Nanyang Ye, Zhanxing Zhu, Rafal Mantiuk

Training modern deep neural networks (DNNs) is essentially an exercise in high-dimensional, non-convex optimization. The "energy landscape" (or loss function) of a DNN is littered with countless local minima and saddle points. A major hurdle is that standard optimizers like Stochastic Gradient Descent (SGD) often get trapped in "sharp" local minima. While these points show low error on training data, they generalize poorly to unseen data.

Previous attempts to solve this issue relied on Simulated Annealing, where a "temperature" parameter is manually lowered over time to help the model hop out of bad spots. However, these methods are notoriously sensitive: cool the system too quickly, and it gets stuck; too slowly, and training takes forever.

Continuously Tempered Langevin Dynamics (CTLD)

To address these limitations, researchers have introduced Continuously Tempered Langevin Dynamics (CTLD), a novel two-phase training strategy. By treating temperature as a dynamic variable that adjusts itself automatically, the algorithm effectively explores complex loss landscapes to find "flat" minima—which are known to generalize better—before fine-tuning with standard optimization.

A Two-Phase Approach

  1. The Bayesian Sampling Phase: Instead of merely descending the gradient, the model uses Langevin Dynamics, which is essentially SGD injected with a specific amount of Gaussian noise. The key innovation is Continuous Tempering. The authors add an augmented variable ($\alpha$) that controls the temperature. This variable has its own dynamics, allowing the model to automatically heat up to escape a local minimum or cool down to explore a promising region. To ensure the temperature variable explores its full range without getting stuck, the system employs Metadynamics, a technique borrowed from molecular dynamics.
  2. The Optimization Phase: Once the sampler has identified a "fat" (broad and flat) mode in the landscape, the model switches to standard SGD with momentum to fine-tune the parameters.
MSE comparison of CTLD against standard optimizers

Experimental Validation and Key Insights

The authors evaluated CTLD against popular optimizers (Adam, RMSprop, SGD-M, etc.) across several tasks, including training Stacked Denoising Autoencoders on MNIST and a 3-layer LSTM for character-level language modeling on the Wikipedia Hutter Prize dataset.

  • "Fat" Modes are Better: The central philosophy is that flat minima contain more probability mass and are more robust to perturbations than sharp ones. Bayesian sampling is naturally drawn to these regions.
  • Self-Governing Temperature: Unlike traditional annealing, which follows a rigid, human-defined schedule, CTLD’s temperature reacts to the loss landscape, providing a principled way to explore.
  • Hybrid Vigor: The paper demonstrates that sampling and optimization aren't mutually exclusive. Using a sophisticated sampler to initialize a standard optimizer combines the global exploration of Bayesian methods with the local efficiency of frequentist optimization.

Key Results

CTLD demonstrated superior generalization capabilities. On the Wikipedia character prediction task, CTLD achieved significantly lower training and test perplexity than Adam and RMSprop. While standard optimizers converged quickly at first, they ultimately became trapped in inferior local minima.

Test Perplexity vs. Epoch for LSTM on Wikipedia dataset

Furthermore, sensitivity analysis (conducted on Tolstoy's War and Peace) showed that CTLD is relatively stable across a range of hyperparameter settings, making it practical for real-world use. Despite the added complexity of the temperature dynamics, the computational overhead is negligible; CTLD's per-epoch time was comparable to, and sometimes faster than, Adam.

Limitations and Future Work

While CTLD automates temperature scaling, users still need to tune standard hyperparameters like learning rate and momentum. Additionally, the current experiments focused on Autoencoders and LSTMs. Testing the algorithm on more modern architectures, such as Transformers or very deep Residual Networks, remains a natural next step. Finally, the authors suggest that incorporating higher-order numerical integrators or preconditioners could further accelerate the convergence speed of the sampling phase.

Summary updated

BibTeX
@inproceedings{ye2017langevin,
  author = {Nanyang Ye and Zhanxing Zhu and Rafal Mantiuk},
  title = {{Langevin Dynamics with Continuous Tempering for Training Deep Neural Networks}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2017},
}
Figure