A Layer-Wise Natural Gradient Optimizer for Training Deep Neural Networks

Xiaolei Liu, Shaoshuai Li, Kaixin Gao, Binfeng WangNeurIPS 2024

Introduction

Training deep neural networks (DNNs) traditionally relies on first-order optimizers like Stochastic Gradient Descent (SGD) or Adam. While computationally inexpensive, these methods only consider the gradient's direction, which can lead to slow convergence and high sensitivity to hyperparameters.

Second-order optimization algorithms, such as Natural Gradient Descent (NGD), offer a theoretically superior alternative. By utilizing the "curvature" of the loss landscape—represented by the Fisher Information Matrix (FIM)—NGD can take much smarter, more efficient steps. However, the FIM is gargantuan. For a model with millions of parameters, computing and inverting this matrix is computationally prohibitive. Existing approximations like Kronecker-factored Approximate Curvature (KFAC) help mitigate this, but they still require expensive back-propagation and matrix inversions that often negate their theoretical speed advantages.

The Layer-Wise Natural Gradient Optimizer (LNGD) bridges this gap, making second-order optimization practical for massive deep learning models. By combining a novel "diagonal-Kronecker" approximation of the FIM with an adaptive layer-wise learning rate, LNGD achieves state-of-the-art accuracy significantly faster than Adam or KFAC.

The LNGD Solution

The authors introduce the LNGD optimizer, which slashes the overhead of second-order optimization through three primary innovations:

1. Layer-wise Sample Approximation

Instead of performing a full, expensive back-propagation to compute the FIM, the authors assume the predictive distribution of each layer follows a Gaussian distribution. This assumption allows them to estimate the FIM blocks for each layer using only local inputs and outputs. Because these blocks are computed layer-by-layer using local data, matrix inversions can occur during the forward pass or independently, removing the bottleneck of waiting for a full backward pass to complete.

2. Diagonal-Kronecker Factorization

Standard KFAC approximates the FIM as a Kronecker product of two matrices. LNGD takes this a step further by forcing one of those matrices to be diagonal.

Visual comparison of Fisher Information Matrix block approximations.

This drastically reduces the computational cost of matrix inversion while preserving the most critical curvature information. The authors observed that the principal diagonal of the FIM contains the most significant information; by prioritizing these elements, LNGD maintains the benefits of second-order optimization with a fraction of the mathematical overhead.

3. Adaptive Layer-wise Learning Rate

Rather than relying on a single global learning rate, LNGD derives a specific rate for each layer by optimizing a quadratic model of the loss. This acts as an automatic "gearbox," ensuring that layers with smaller gradients aren't left behind and allowing different parts of the network to converge at their own optimal speeds without manual tuning.

Experimental Results

The researchers evaluated LNGD across three diverse and standard benchmarks, demonstrating that it consistently outperforms standard first-order and second-order optimizers in "time-to-accuracy":

  • CIFAR-10 (ResNet-18): LNGD reached 91% accuracy in just 36 epochs (189.69 seconds). For comparison, SGD took 79 epochs and Adam took 72. LNGD was 21% faster than the previous best second-order method, KFAC.
  • ImageNet-1K (ResNet-50): To reach 75.9% accuracy, LNGD required only 36 epochs and 6.46 hours. This represents a 19% reduction in computing time compared to KFAC, and a massive improvement over SGD, which required 78 epochs.
  • WMT English-German (Transformer-Big): On this massive 213.7M parameter machine translation task, LNGD reached a target Bleu score of 32 24% faster than KFAC and 16% faster than Adam. Notably, SGD failed to reach the target score entirely.

Limitations and Future Work

While LNGD presents a significant leap forward, it does have limitations. The efficiency of the layer-wise sampling relies heavily on the assumption that predictive distributions are Gaussian. While empirical evidence supports this for ReLU networks, it may not be as effective for all architectures or activation functions.

Additionally, although the learning rate is adaptive, LNGD introduces new hyperparameters, such as damping constants and update intervals for the FIM. Finally, LNGD is inherently more complex to implement than simple first-order methods, which might temporarily hinder its immediate, out-of-the-box adoption in standard deep learning libraries.

Future work will likely focus on refining the global convergence analysis and exploring how LNGD scales to even larger "foundation" models with billions of parameters, where efficient second-order optimization could unlock unprecedented training speeds.

Summary updated

BibTeX
@inproceedings{liu2024layer,
  author = {Xiaolei Liu and Shaoshuai Li and Kaixin Gao and Binfeng Wang},
  title = {{A Layer-Wise Natural Gradient Optimizer for Training Deep Neural Networks}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=niG3Yyb6oA},
}
Figure