NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

DrMAD: Distilling Reverse-Mode Automatic Differentiation for Optimizing Hyperparameters of Deep Neural Networks

Jie Fu, Hongyin Luo, Jiashi Feng, Kian Hsiang Low, Tat-Seng Chua

Abstract

The performance of deep neural networks is well-known to be sensitive to the setting of their hyperparameters. Recent advances in reverse-mode automatic differentiation allow for optimizing hyperparameters with gradients. The standard way of computing these gradients involves a forward and backward pass of computations. However, the backward pass usually needs to consume unaffordable memory to store all the intermediate variables to exactly reverse the forward training procedure. In this work we propose a simple but effective method, DrMAD, to distill the knowledge of the forward pass into a shortcut path, through which we approximately reverse the training trajectory. Experiments on two image benchmark datasets show that DrMAD is at least 45 times faster and consumes 100 times less memory compared to state-of-the-art methods for optimizing hyperparameters with minimal compromise to its effectiveness. To the best of our knowledge, DrMAD is the first research attempt to make it practical to automatically tune thousands of hyperparameters of deep neural networks.

Introduction

Hyperparameters, such as learning rates and regularization penalties, are critical to the success of deep learning models. Traditionally, these are tuned using methods like Grid Search or Bayesian Optimization. While effective for a small number of parameters, these methods fail to scale when the number of hyperparameters exceeds a few dozen.

Gradient-based optimization using Reverse-Mode Automatic Differentiation (RMAD) offers a solution by calculating "hypergradients"—the gradient of the validation loss with respect to hyperparameters. However, RMAD faces a significant "memory wall." To compute exact hypergradients, one must store the model's weights at every training iteration to reverse the trajectory. For modern deep networks, this memory requirement is often prohibitive.

The DrMAD Method: Distilling the Training Trajectory

The core innovation of this work is DrMAD (Distilling Reverse-Mode Automatic Differentiation). The authors propose a "Shortcut Path" to bypass the memory constraints of exact RMAD. Instead of storing every intermediate state to track the complex, non-linear path of Stochastic Gradient Descent (SGD), DrMAD approximates the training trajectory as a linear interpolation between the initial weights ($w_0$) and the final trained weights ($w_T$).

Visualization of the training trajectory and the DrMAD linear shortcut.

The process involves:

  1. Forward Pass: The model is trained to convergence using standard SGD. Only the initial and final weights are saved, making memory usage constant regardless of the number of training iterations.
  2. Backward Pass: DrMAD computes hypergradients by "reversing" along the straight-line shortcut from $w_T$ back to $w_0$.

This approximation significantly reduces both computational time and memory overhead. By decoupling the weight optimization from hyperparameter optimization, DrMAD can be easily integrated into existing deep learning frameworks.

Distributed Hyperparameter Optimization

To further scale the method, the authors introduce a Hyperparameter Server architecture. In this setup, multiple clients compute hypergradients on different subsets of data. These gradients are then aggregated by a central server to update the global hyperparameters. This distributed approach allows for tuning thousands of hyperparameters simultaneously across large datasets.

Experimental Results

The effectiveness of DrMAD was evaluated on the MNIST and Omniglot datasets. On MNIST, DrMAD achieved a 45x speedup and a 100x reduction in memory consumption compared to previous state-of-the-art gradient-based methods.

Comparison of DrMAD and RMAD on MNIST in terms of regularization values and test error.

Despite the aggressive linear approximation, the test error rates remained comparable to exact methods. Furthermore, the authors demonstrated the ability to tune 934 hyperparameters at once—specifically, individual $L_2$ penalties for every neuron in a multi-layer perceptron—a task that is computationally infeasible for non-gradient-based optimization techniques.

Conclusion

DrMAD provides a practical and highly efficient framework for high-dimensional hyperparameter optimization in deep neural networks. By distilling the training trajectory into a linear shortcut, it overcomes the memory limitations of standard RMAD while maintaining competitive performance. This work opens the door to automatically tuning thousands of hyperparameters, potentially leading to more robust and better-performing deep learning models.

Summary updated

BibTeX
@inproceedings{fu2016drmad,
  author = {Jie Fu and Hongyin Luo and Jiashi Feng and Kian Hsiang Low and Tat-Seng Chua},
  title = {{DrMAD: Distilling Reverse-Mode Automatic Differentiation for Optimizing Hyperparameters of Deep Neural Networks}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {2016},
  url = {https://openreview.net/forum?id=BkZcNNGuZr},
}
Figure