Random Function Descent

Felix Benning, Leif Döring

In the world of machine learning, practitioners often rely on "folk wisdom" heuristics to train models—techniques like learning rate warmup and gradient clipping. While these tricks are undeniably effective in practice, classical optimization theory, which typically assumes "worst-case" convex functions, struggles to explain why they work so well.

A new paper from researchers at the University of Mannheim, titled Random Function Descent (RFD), proposes a fundamental shift in perspective: what if we stop assuming the worst-case scenario and start optimizing for the "average" case?

The Problem with Classical Optimization

Classical optimization theory is largely built on the concept of $L$-smoothness, which provides a "worst-case" upper bound on how much a gradient can change. This mathematical foundation guarantees convergence, but the resulting learning rates are often far too conservative for real-world deep learning tasks.

To bridge this gap, practitioners use heuristics like learning rate warmup (starting with a small rate and gradually increasing it) and gradient clipping (capping the maximum step size). While successful, these methods lack a unified theoretical framework, particularly in the highly non-convex initial stages of training.

An alternative theoretical approach is standard Bayesian Optimization (BO), which does use a random function perspective. However, BO is computationally prohibitive in high dimensions, scaling at $\mathcal{O}(n^3d^3)$ (where $n$ is the number of steps and $d$ is the number of dimensions), making it entirely unusable for training modern neural networks.

Methods: The Random Function Framework

The authors introduce Random Function Descent (RFD) to bridge the gap between Bayesian Optimization and classical gradient-based methods. RFD replaces the traditional polynomial Taylor approximation with a "stochastic Taylor approximation."

Instead of a rigid linear approximation, RFD defines the approximation as the conditional expectation of a random function given the current value and gradient: $\mathbb{E}[\mathbf{J}(\theta) | \mathbf{J}(w), \nabla \mathbf{J}(w)]$.

Stochastic Taylor Approximation

Key technical components of this approach include:

  • Isotropic Gaussian Priors: By assuming the cost function is a "random field" that behaves similarly in every direction (isotropy), the authors prove that the optimal descent direction is exactly the negative gradient.
  • Scalable Complexity: Unlike standard BO, RFD achieves $\mathcal{O}(nd)$ complexity. This matches the computational efficiency of standard Gradient Descent, making it viable for high-dimensional machine learning.
  • Non-parametric Variance Estimation: The algorithm estimates the "landscape" of the function—its variance and length scale—on the fly by performing linear regression on different mini-batch sizes. This allows the optimizer to dynamically set its own step sizes without manual tuning.

Key Insights: Justifying Folk Wisdom

By shifting to an average-case, random function perspective, RFD provides a rigorous theoretical foundation for several common deep learning heuristics:

  • Gradient Descent is "Average-Case" Optimal: If you assume your loss landscape is a random isotropic function, following the negative gradient isn't just a convenient heuristic—it is the mathematically optimal direction to minimize the expected loss.
  • Theoretical Basis for Warmup: RFD naturally produces a step-size schedule that mimics learning rate warmup. Early in optimization, the "gradient cost quotient" is high, leading the algorithm to take smaller, cautious steps. As the optimizer gains "certainty" about the local landscape, the step size gradually increases.
  • Scale Invariance: Scaling a loss function (e.g., switching from Mean Squared Error to Sum of Squared Errors) typically requires re-tuning the learning rate. RFD is inherently scale-invariant; it automatically adjusts to additive shifts or positive scaling of the cost function.
  • Gradient Clipping as a Trust Bound: RFD's calculated optimal step size naturally plateaus when gradients become very large. This built-in ceiling provides a formal, mathematical justification for the practice of gradient clipping.
RFD Step Size Plateau

Empirical Results

The authors evaluated RFD on standard image recognition benchmarks, including MNIST and Fashion MNIST. In head-to-head tests, RFD (utilizing covariance models like Squared Exponential and Matérn) performed comparably to—and sometimes better than—meticulously tuned Adam and SGD optimizers.

Crucially, while Adam and SGD required an extensive "tuning" phase to find the optimal learning rate (a process that often costs more compute than the actual training), RFD required zero manual learning rate tuning. It successfully estimated the necessary parameters directly from the data and converged to the same performance levels.

Limitations and Future Work

The authors are transparent about the limitations of RFD, noting its "risk-affine" nature. Because it optimizes for the average case rather than the worst case, it can sometimes take steps that are too aggressive. This was observed on the more complex CIFAR-100 dataset, where the algorithm's large steps led to instability.

To address this, future research directions include:

  1. Relaxing Isotropy: Moving toward "geometric anisotropies" to better model loss landscapes that are steeper in some directions than others, similar to how Adam utilizes adaptive per-parameter learning rates.
  2. Adding Memory: RFD is currently "forgetful," much like standard Gradient Descent. Incorporating momentum could significantly boost its performance and stability.
  3. Handling Non-Stationarity: Developing models that account for the fact that the "texture" of the loss landscape fundamentally changes as the optimizer moves from initial random weights toward a local minimum.

Summary updated

BibTeX
@inproceedings{benning2024random,
  author = {Felix Benning and Leif Döring},
  title = {{Random Function Descent}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=xzCuBjHQbS},
}
Figure