On the Promise of the Stochastic Generalized Gauss-Newton Method for Training DNNs

Matilde Gargiani, Andrea Zanelli, Moritz Diehl, Frank HutterarXiv 2020

Abstract

Following early work on Hessian-free methods for deep learning, we study a stochastic generalized Gauss-Newton method (SGN) for training DNNs. SGN is a second-order optimization method, with efficient iterations, that we demonstrate to often require substantially fewer iterations than standard SGD to converge. As the name suggests, SGN uses a Gauss-Newton approximation for the Hessian matrix, and, in order to compute an approximate search direction, relies on the conjugate gradient method combined with forward and reverse automatic differentiation. Despite the success of SGD and its first-order variants, and despite Hessian-free methods based on the Gauss-Newton Hessian approximation having been already theoretically proposed as practical methods for training DNNs, we believe that SGN has a lot of undiscovered and yet not fully displayed potential in big mini-batch scenarios. For this setting, we demonstrate that SGN does not only substantially improve over SGD in terms of the number of iterations, but also in terms of runtime. This is made possible by an efficient, easy-to-use and flexible implementation of SGN we propose in the Theano deep learning platform, which, unlike Tensorflow and Pytorch, supports forward automatic differentiation. This enables researchers to further study and improve this promising optimization technique and hopefully reconsider stochastic second-order methods as competitive optimization techniques for training DNNs; we also hope that the promise of SGN may lead to forward automatic differentiation being added to Tensorflow or Pytorch. Our results also show that in big mini-batch scenarios SGN is more robust than SGD with respect to its hyperparameters (we never had to tune its step-size for our benchmarks!), which eases the expensive process of hyperparameter tuning that is instead crucial for the performance of first-order methods.

Introduction

Stochastic Gradient Descent (SGD) and its first-order variants (e.g., Adam) are the standard for training deep neural networks. However, these methods often struggle with "pathological curvature"—regions where the loss landscape is poorly conditioned—leading to slow convergence. Additionally, first-order methods are highly sensitive to hyperparameters like the learning rate, necessitating extensive tuning.

Second-order methods utilize curvature information (the Hessian matrix) to navigate these landscapes more effectively. Historically, they have been avoided due to the prohibitive cost of computing and storing the Hessian. This paper investigates the Stochastic Generalized Gauss-Newton (SGN) method, demonstrating its practical superiority in modern "big mini-batch" training environments.

Methodology

SGN is a "Hessian-free" second-order approach that leverages several key techniques:

  • Gauss-Newton Approximation: Instead of the exact Hessian, SGN uses the Gauss-Newton matrix, which is positive semi-definite by construction, ensuring stable optimization.
  • Conjugate Gradient (CG) Method: To avoid the $O(d^2)$ cost of Hessian storage, CG is used to solve for the update direction using only matrix-vector products.
  • Automatic Differentiation (AD): The implementation combines forward and reverse mode AD. Forward AD efficiently computes Jacobian-vector products, a feature the authors utilized via the Theano platform.
  • Levenberg-Marquardt Regularization: A damping term ($\rho I$) is incorporated to control the "trust region" and ensure the system remains well-conditioned.

Experimental Results

The authors evaluated SGN across regression (Boston Housing, Sine Wave) and classification (MNIST, FashionMNIST, CIFAR10) tasks.

Convergence and Time Efficiency

In large mini-batch scenarios, SGN's ability to extract more information per iteration allows it to converge in significantly fewer epochs. When batches are large enough to saturate GPU parallelization, SGN outperforms SGD in total wall-clock time.

Test loss vs. training time (sec) comparing SGD and SGN variants.

As shown in Figure 1, SGN variants (dashed lines) achieve orders of magnitude lower test loss significantly faster than SGD variants (solid lines) in regression tasks.

Benchmark Performance

On the MNIST dataset, SGN demonstrated superior accuracy and efficiency compared to standard first-order baselines.

Comparison of Test Accuracy and convergence epochs for MNIST.

According to the results in Figure 5, SGN (with 3 CG iterations) reached 94.0% test accuracy in just 33 epochs, whereas the best-tuned SGD required 144 epochs to reach a lower 93.0% accuracy. Similar trends were observed for CIFAR10, where SGN achieved 71.0% accuracy in 9 epochs, compared to SGD's 60.9% in 135 epochs.

Discussion and Conclusion

A major advantage of SGN is its hyperparameter robustness; the authors reported that the step-size never required tuning across benchmarks. However, SGN is sensitive to mini-batch size, requiring larger batches to accurately estimate curvature. Future work includes developing adaptive schemes for CG iterations and damping parameters. The study also emphasizes the need for forward-mode AD support in mainstream frameworks like PyTorch and TensorFlow to facilitate the adoption of second-order methods.

Summary updated

BibTeX
@misc{gargiani2020promise,
  author = {Matilde Gargiani and Andrea Zanelli and Moritz Diehl and Frank Hutter},
  title = {{On the Promise of the Stochastic Generalized Gauss-Newton Method for Training DNNs}},
  year = {2020},
  eprint = {2006.02409},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2006.02409},
}
Figure