Understanding Gradient Regularization in Deep Learning: Efficient Finite-Difference Computation and Implicit Bias

Ryo Karakida, Tomoumi Takase, Tomohiro Hayase, Kazuki Osawa

Introduction

Gradient Regularization (GR)—the practice of penalizing the norm of the loss gradient during training—is a powerful technique for improving model generalization. Deep learning models often converge to "sharp" minima, which are regions in the loss landscape where minute parameter changes cause significant jumps in error, typically correlating with poor generalization on unseen data. GR combats this by encouraging the optimizer to seek out "flatter," more robust regions.

Despite its benefits, GR has traditionally faced two major hurdles. First is the computational cost: the standard implementation relies on "Double Backpropagation" (DB), which requires computing the gradient of a gradient (a Hessian-vector product). This is notoriously slow and memory-intensive. Second is the theoretical mystery: it remains unclear exactly why different algorithmic implementations of GR yield different generalization outcomes.

This paper demonstrates that a simple finite-difference approximation of GR is not only twice as fast as standard DB but actually yields superior accuracy by providing a stronger implicit bias toward sparse, high-performing solutions.

Methods: Approximating the Gradient

To understand the mechanics of GR, the researchers compared three primary methods for computing the regularization term:

  1. Double Backpropagation (DB): The "exact" method, utilizing automatic differentiation to compute the Hessian-vector product.
  2. Forward Finite-Difference (F-GR): An approximation of the second-order information. It takes a small step $\epsilon$ in the direction of the gradient and calculates the difference: $\frac{\nabla \mathcal{L}(\theta + \epsilon \nabla \mathcal{L}) - \nabla \mathcal{L}(\theta)}{\epsilon}$.
  3. Backward Finite-Difference (B-GR): Similar to F-GR, but stepping in the opposite direction (against the gradient).

To analyze the theoretical underpinnings, the authors utilized a Diagonal Linear Network (DLN)—a simplified, mathematically solvable model. This allowed them to track the optimizer's "implicit bias," specifically observing whether it favored the "lazy regime" (simple L2-style solutions) or the "rich regime" (complex, sparse L1-style solutions that generally generalize better). The findings were validated on standard benchmarks (CIFAR-10, CIFAR-100) using architectures like MLPs, ResNet-18/34, and WideResNet-28-10.

Key Results: Speed and Generalization

Surprisingly, the finite-difference approximation (F-GR) consistently outperformed the exact calculation (DB). The "noise" introduced by the finite step size $\epsilon$ actively helps the model explore the loss landscape more effectively.

Comparison of Wall Time and Test Accuracy between F-GR and DB

As shown above, F-GR provides a massive efficiency boost. Because F-GR only requires one additional gradient evaluation per step, it is roughly 2x faster than Double Backpropagation per epoch on ResNet architectures. Furthermore, this speed does not come at the cost of performance. On CIFAR-10 with ResNet-18, F-GR achieved a test accuracy of ~87.0%, noticeably higher than the 86.3% achieved by DB, and reached peak accuracy in significantly less wall-clock time.

Theoretical and empirical results in DLNs also showed that F-GR leads to much lower L1 norms (higher sparsity) than training without GR, confirming its desirable bias toward the "rich regime."

Direction Matters: F-GR vs. B-GR

The direction of the finite-difference step plays a critical role in the model's final performance. Stepping forward (F-GR) strengthens the bias toward the "rich regime," promoting desirable sparse solutions. Conversely, stepping backward (B-GR) pushes the model toward the "lazy regime," degrading generalization.

Heatmaps showing Test Accuracy for F-GR and B-GR across hyperparameters

The heatmaps above illustrate the hyperparameter sensitivity of both methods on ResNet-18. F-GR exhibits a much broader region of high test accuracy (lighter colors) across various combinations of the step size ($\epsilon$) and the regularization coefficient ($\gamma$). B-GR, on the other hand, struggles to achieve the same peak performance and is far more brittle.

Interestingly, the paper also reveals a hidden mathematical link to "Flooding"—a technique that prevents the training loss from dropping below a specified threshold. The authors prove that Flooding essentially acts as an implicit version of F-GR, further bridging the gap between different regularization strategies.

Limitations and Future Work

While F-GR is highly effective, its success depends heavily on choosing the right step size ($\epsilon$) and regularization coefficient ($\gamma$), which currently requires grid searching. Additionally, while the DLN analysis provides rigorous mathematical proof of the implicit bias, extending these theoretical guarantees to fully non-linear, deep architectures remains an open challenge. Future work may explore dynamic schedules for the ascent step size $\epsilon$, decaying it over time much like a learning rate schedule, to further stabilize and optimize training.

Summary updated

BibTeX
@inproceedings{karakida2023understanding,
  author = {Ryo Karakida and Tomoumi Takase and Tomohiro Hayase and Kazuki Osawa},
  title = {{Understanding Gradient Regularization in Deep Learning: Efficient Finite-Difference Computation and Implicit Bias}},
  booktitle = {International Conference on Machine Learning},
  year = {2023},
  url = {https://openreview.net/forum?id=Ug2RRD5Pf3},
}
Figure