Optimizing Millions of Hyperparameters by Implicit Differentiation

Jonathan Lorraine, Paul Vicol, David Duvenaud

Abstract

We propose an algorithm for inexpensive gradient-based hyperparameter optimization that combines the implicit function theorem (IFT) with efficient inverse Hessian approximations. We present results on tuning millions of hyperparameters, demonstrating high scalability and improved generalization across various deep learning tasks.

Introduction

Hyperparameter optimization (HO) is a cornerstone of modern machine learning, yet it frequently encounters a "dimensionality wall." Traditional methods like random search or Bayesian optimization are effective for a handful of parameters but struggle to scale beyond 100 dimensions. To tune millions of hyperparameters—such as individual weight decay values for every connection in a neural network—gradient-based approaches are required.

However, computing "hypergradients" (the gradient of validation loss with respect to hyperparameters) is computationally demanding. It typically requires either "unrolling" the entire training trajectory, which is memory-intensive, or inverting the training Hessian matrix, which is computationally prohibitive for large-scale models. This paper introduces a middle ground: a method that leverages the Implicit Function Theorem (IFT) to achieve memory efficiency and computational tractability at scale.

Methodology

The core of the proposed approach is the application of the Implicit Function Theorem to compute hypergradients. The primary challenge in this framework is the requirement for an inverse Hessian-vector product. The authors introduce several innovations to make this tractable:

  1. Neumann Series Approximation: Instead of an exact matrix inversion, the inverse Hessian is approximated using a Neumann series: $[H]^{-1} \approx \sum_{j=0}^{i} (I - \alpha H)^j$. This allows the inverse Hessian-vector product to be computed using only efficient Hessian-vector products (HVPs).
  2. Constant Memory Cost: Unlike unrolled differentiation, which requires storing the optimization history, this method maintains a constant memory footprint regardless of the number of approximation steps.
  3. Theoretical Unification: The authors demonstrate that unrolled differentiation for $i$ steps is essentially equivalent to taking the first $i$ terms of the Neumann series, providing a unified view of these two common HO techniques.
Conceptual overview of HO: The implicit function $w^*(\lambda)$ represents the best-response of weights to hyperparameters. The hypergradient (red) tracks validation loss changes along this manifold.

Experimental Setup

The algorithm was evaluated across several diverse tasks:

  • Dataset Distillation: Learning synthetic datasets (e.g., 10 images) that summarize full training sets like MNIST and CIFAR-10.
  • Learned Data Augmentation: Tuning a U-Net "augmentation network" as a set of hyperparameters to improve a ResNet18 classifier on CIFAR-10.
  • Regularization Tuning: Optimizing millions of dropout and weight decay parameters for LSTM-based language models on the Penn Treebank (PTB) dataset.
  • Small-scale Analysis: Visualizing Hessian structures and performing initial tests on the Boston Housing dataset.

Discussion: Neumann vs. Conjugate Gradient

A key technical insight involves the choice of linear solver. While Conjugate Gradient (CG) is a standard choice for solving linear systems, the authors found that the Neumann series approximation is more stable in the stochastic settings typical of deep learning. Empirically, the Neumann scheme often provides a gradient direction with higher cosine similarity to the true gradient compared to CG.

Comparison of Neumann and CG approximations: The Neumann scheme demonstrates higher cosine similarity to the true gradient, indicating a more accurate gradient direction in stochastic settings.

Furthermore, the authors highlight the risk of validation overfitting. When tuning millions of hyperparameters, it is possible to "memorize" the validation set. Mitigating this requires larger validation partitions and careful re-training on combined datasets to ensure generalization to test data.

Key Results

The proposed algorithm demonstrates remarkable scalability and performance:

  • Extreme Scale: The method successfully tuned over 50 million hyperparameters for an AlexNet model, enabling it to achieve 100% validation accuracy on a small dataset by effectively memorizing labels through per-parameter regularization.
  • Generalization Gains: On CIFAR-10, learning a data augmentation network improved ResNet18 accuracy by 2-3% over standard training baselines.
  • Efficiency: For LSTMs on Penn Treebank, the method tuned millions of parameters faster than competing methods could tune just seven, while achieving superior test perplexity.

Conclusion

While highly effective, the method requires continuous hyperparameters and assumes the inner optimization reaches a fixed point. Future work may address discrete hyperparameter optimization or extend the framework to tune optimizer parameters like learning rate schedules. This research paves the way for practical nested optimization in complex domains such as GAN training and multi-agent reinforcement learning.

Summary updated

BibTeX
@inproceedings{lorraine2020optimizing,
  author = {Jonathan Lorraine and Paul Vicol and David Duvenaud},
  title = {{Optimizing Millions of Hyperparameters by Implicit Differentiation}},
  booktitle = {International Conference on Artificial Intelligence and Statistics},
  year = {2020},
  url = {https://openreview.net/forum?id=rzzWbofuIe5},
}
Figure