Abstract: Working with any gradient-based machine learning algorithm involves the tedious task of tuning the optimizer's hyperparameters, such as its step size. Recent work has shown how the step size can itself be optimized alongside the model parameters by manually deriving expressions for "hypergradients" ahead of time. We show how to automatically compute hypergradients with a simple and elegant modification to backpropagation. This allows us to easily apply the method to other optimizers and hyperparameters (e.g. momentum coefficients). We can even recursively apply the method to its own hyper-hyperparameters, and so on ad infinitum. As these towers of optimizers grow taller, they become less sensitive to the initial choice of hyperparameters. We present experiments validating this for MLPs, CNNs, and RNNs. Finally, we provide a simple PyTorch implementation of this algorithm.
Introduction
Training deep neural networks is notoriously sensitive to hyperparameters, particularly the learning rate ($\alpha$). If $\alpha$ is too small, training is agonizingly slow; if it is too large, the model fails to converge. Finding the "just right" value usually requires tedious manual tuning or expensive grid searches. While previous research suggested using "hypergradients"—the gradient of the loss with respect to the learning rate—to update $\alpha$ during training, these methods relied on manual mathematical derivations. This made them difficult to scale to complex optimizers like Adam or to "hyper-hyperparameters" (the learning rate for the learning rate), creating a "turtles all the way down" problem where every new optimizer level introduced a new parameter to tune.
Automated Hypergradients and Recursive Stacking
The authors propose a fully automated approach using Automatic Differentiation (AD). Instead of deriving formulas by hand, they use AD to compute derivatives for any hyperparameter. The key implementation trick is careful management of the computation graph: they "detach" the model weights at each step to keep memory usage constant, but keep the hyperparameters attached to allow gradient flow back through the optimization step.
This architecture naturally supports a "tower" of optimizers. Level 0 optimizes the model weights. Level 1 (the hyperoptimizer) optimizes Level 0's hyperparameters. Level 2 optimizes Level 1's hyperparameters, and so on. Because the method uses AD, it works "for free" on any differentiable hyperparameter, including momentum coefficients in Adam or decay terms in RMSProp.
Experimental Evaluation
The authors evaluated their method across several standard benchmarks:
- MNIST: Used for initial tests with Multi-Layer Perceptrons (MLPs).
- CIFAR-10: Used to train ResNet-20 architectures for computer vision.
- Tolstoy Dataset: A character-level language modeling task using Recurrent Neural Networks (RNNs).
- Caltech-256: Used for fine-tuning a large, pre-trained ResNet-152 model.
Key Results and Insights
The experiments revealed several compelling properties of the hyperoptimizer:
- Tower Robustness: As the stack of optimizers grows taller, the system becomes increasingly indifferent to the initial hyperparameter choice. A 3-level stack can achieve good results even if the base learning rate is off by several orders of magnitude.
- Emergent Schedules: The hyperoptimizer naturally "discovers" effective learning rate schedules. For example, when training a ResNet, the hyperoptimizer automatically learned a decay schedule that closely matched the famous hand-engineered schedule used in the original ResNet paper.
- Negligible Overhead: Because hyperoptimizers only perform a few extra scalar operations per step, each additional level in the stack only adds about 1–2% to the total runtime.
Conclusion
This work demonstrates that the optimization process itself can be effectively optimized using standard backpropagation techniques. While robust, the system can still diverge if initial hyperparameters are so high that the model explodes before the hyperoptimizer can correct them. Additionally, some "black box" modules in deep learning libraries are currently incompatible with this AD-based approach. Nonetheless, the ability to automatically tune optimizers with minimal overhead represents a significant step toward more robust and automated machine learning workflows.
Summary updated