Search

Search papers and lessons

Natural Gradient Descent

Level 3 · 11 min read

Natural gradient descent steps in the direction that changes the model's probabilities most per unit of change, by rescaling the ordinary gradient with the inverse Fisher information.

On this page

  • Colour = topic mix
  • Calculus
  • Discrete math
  • Probability
  • Linear algebra
  • Inference
  • Optimizers
  • ReadReady to readNot yet

TL;DR

Natural gradient descent is gradient descent with a correction for the geometry of the model. The ordinary gradient points in the steepest direction in the raw numbers of the parameters, which is not the same as the steepest direction in the probabilities the model assigns. The natural gradient multiplies the ordinary gradient by the inverse of the Fisher information matrix, which measures how sensitive those probabilities are to each parameter. The result does not depend on how the parameters happen to be labelled.

Builds on: Gradient Descent, Fisher Information · Leads to: Kullback–Leibler Divergence (the distance the method is measured in)

Where it's used

Training neural networks. Plain gradient descent struggles on deep networks because layers have very different sensitivities, so one learning rate fits some directions and not others. Kronecker-factored approximate curvature, or K-FAC, is a practical approximation to the natural gradient that James Martens and Roger Grosse introduced in 2015. On the benchmark problems its authors tested, it reduced the number of training steps compared with plain stochastic gradient descent, at a higher cost per step.

Reinforcement learning. A policy is a probability distribution over actions, so changing its parameters changes the probabilities directly. This is the setting of Reinforcement Learning. Sham Kakade's natural policy gradient used this geometry, and Schulman and colleagues' 2015 Trust Region Policy Optimization (TRPO) took a natural-gradient-like step while limiting how far the policy moves, measured in KL divergence.

Variational inference. Variational methods fit a simple probability distribution to a harder one by adjusting that simple distribution's parameters. The same family can be written with different parameters, and the step should not depend on the writing. Natural-gradient updates are used in many variational methods for this reason.

How it works

Here is one tiny instance traced from start to finish: a single parameter θ\theta, the probability that a coin lands heads. Assume the current value is θ=0.8\theta = 0.8, and the gradient of the loss with respect to θ\theta is 0.50.5. The learning rate is η=0.1\eta = 0.1.

  1. Start with the current value θ=0.8\theta = 0.8 and the gradient g=0.5g = 0.5. The gradient says the loss would fall if θ\theta went down.
  2. Take the plain gradient step: θ−ηg=0.8−0.1×0.5=0.75\theta - \eta g = 0.8 - 0.1 \times 0.5 = 0.75. Check: 0.8−0.05=0.750.8 - 0.05 = 0.75.
  3. Measure how sensitive the coin's outcomes are to θ\theta at this point. This is the Fisher information, I(θ)=1θ(1−θ)I(\theta) = \frac{1}{\theta(1-\theta)}. It comes from the score (the slope of the log-probability): when heads, the score is 1/θ1/\theta; when tails, it is −1/(1−θ)-1/(1-\theta). Averaging the squared score gives θ⋅1θ2+(1−θ)⋅1(1−θ)2=1θ(1−θ)\theta \cdot \frac{1}{\theta^2} + (1-\theta)\cdot\frac{1}{(1-\theta)^2} = \frac{1}{\theta(1-\theta)}. At θ=0.8\theta = 0.8 it is 10.16=6.25\frac{1}{0.16} = 6.25, which is also 10.8+10.2=1.25+5\frac{1}{0.8} + \frac{1}{0.2} = 1.25 + 5. A large value means small changes in θ\theta change the outcome probabilities a lot.
  4. Divide the gradient by that sensitivity: the natural step is θ−η g/I(θ)=0.8−0.1×0.5/6.25=0.792\theta - \eta \, g / I(\theta) = 0.8 - 0.1 \times 0.5 / 6.25 = 0.792. Check: 0.05/6.25=0.0080.05 / 6.25 = 0.008, and 0.8−0.008=0.7920.8 - 0.008 = 0.792.
  5. Compare the two results. The plain step moved θ\theta by 0.050.05, and the KL divergence between the old and new coin is about 0.0080.008 (worked out in the math section). The natural step moved θ\theta by only 0.0080.008, because this coin is sensitive to θ\theta here, and its KL change is about 0.00020.0002. The same gradient asks for a much smaller move where the distribution responds strongly.
flowchart LR
  A[Current parameters] --> B[Compute ordinary gradient]
  A --> C[Compute Fisher matrix]
  B --> D[Multiply gradient by inverse Fisher]
  C --> D
  D --> E[Take step of size eta]
  E --> F[New parameters]

The math

Definition: Fisher information matrix
For a model p(x;θ)p(x;\theta) with parameters θ\theta, the Fisher matrix is F(θ)=E[∇θlog⁡p(X;θ) ∇θlog⁡p(X;θ)⊤]F(\theta) = \mathbb{E}\left[\nabla_\theta \log p(X;\theta)\, \nabla_\theta \log p(X;\theta)^{\top}\right], the average outer product of the score (the gradient of the log-probability), with the average taken over XX drawn from the model. When θ\theta has one entry, it reduces to the Fisher information I(θ)I(\theta) used above.

Step 1 in symbols: the distance that matters

Let L(θ)L(\theta) be the loss. For a small step Δθ\Delta\theta, the loss changes by approximately ∇L⋅Δθ\nabla L \cdot \Delta\theta. The model's distributions change by an amount measured with the KL divergence between the old and new distributions. For a small step, that divergence is approximately

KL(pθ ∥ pθ+Δθ)≈12 Δθ⊤F(θ) Δθ.\mathrm{KL}\big(p_\theta \,\|\, p_{\theta+\Delta\theta}\big) \approx \tfrac{1}{2}\, \Delta\theta^{\top} F(\theta)\, \Delta\theta.

This is the geometry: a step counts as large when it moves the distributions far, and FF says how far each direction moves them. In the coin example, F=I(θ)=6.25F = I(\theta) = 6.25, so the divergence for a step of 0.050.05 is about 12×6.25×0.052=0.0078\frac{1}{2} \times 6.25 \times 0.05^2 = 0.0078.

Step 2 in symbols: the best step for a fixed distance

We want the step that lowers the loss the most while keeping the KL size fixed at some value cc. Minimise ∇L⋅Δθ\nabla L \cdot \Delta\theta subject to 12Δθ⊤FΔθ=c\tfrac{1}{2}\Delta\theta^{\top} F \Delta\theta = c. Introduce a multiplier λ\lambda (a Lagrange multiplier) for the constraint and set the gradient of the Lagrangian to zero:

∇L+λFΔθ=0⟹Δθ=−1λF−1∇L.\nabla L + \lambda F \Delta\theta = 0 \quad\Longrightarrow\quad \Delta\theta = -\frac{1}{\lambda} F^{-1} \nabla L.

So the steepest direction in the model's geometry is F−1∇LF^{-1}\nabla L, and the update is

θt+1=θt−η F(θt)−1∇L(θt).\theta_{t+1} = \theta_t - \eta\, F(\theta_t)^{-1} \nabla L(\theta_t).

With one parameter, this is θ−ηg/I(θ)\theta - \eta g / I(\theta), which is the coin step above.

Step 3 in symbols: what it costs

For a network with nn parameters, FF is an n×nn \times n matrix. A model with ten million parameters would need (107)2=1014(10^7)^2 = 10^{14} entries, and inverting it is far beyond a normal computer. Practical methods replace FF with a cheaper approximation, such as its diagonal (an Adam-like scaling) or, in K-FAC, a product of two small matrices for each layer. The mathematics of the update is unchanged; only the matrix it uses is simpler.

Worked examples

Example
1. A coin with theta at 0.2 (tiny)

Take θ=0.2\theta = 0.2, a gradient g=0.4g = 0.4, and a learning rate η=0.1\eta = 0.1.

  1. The Fisher information is I(θ)=1θ(1−θ)=10.2×0.8=10.16=6.25I(\theta) = \frac{1}{\theta(1-\theta)} = \frac{1}{0.2 \times 0.8} = \frac{1}{0.16} = 6.25.
  2. The plain step is ηg=0.1×0.4=0.04\eta g = 0.1 \times 0.4 = 0.04, so the plain update gives 0.2−0.04=0.160.2 - 0.04 = 0.16.
  3. The natural step is ηg/I=0.04/6.25=0.0064\eta g / I = 0.04 / 6.25 = 0.0064.
  4. The natural update gives 0.2−0.0064=0.19360.2 - 0.0064 = 0.1936.
  5. The natural step is smaller here because the coin is sensitive at this θ\theta (I=6.25I = 6.25). The plain step of 0.040.04 would change the coin's probabilities a lot, so the natural update takes a far smaller move, 0.00640.0064.
Example
2. A Gaussian with mean mu and standard deviation 2 (standard)

The model is a Gaussian with mean μ\mu and standard deviation σ\sigma, with parameters θ=(μ,σ)\theta = (\mu, \sigma). Set σ=2\sigma = 2. The Fisher matrix is diagonal:

F=(1/σ2002/σ2)=(1/4001/2).F = \begin{pmatrix} 1/\sigma^2 & 0 \\ 0 & 2/\sigma^2 \end{pmatrix} = \begin{pmatrix} 1/4 & 0 \\ 0 & 1/2 \end{pmatrix}.
  1. Suppose the ordinary gradient of the loss is ∇L=(1,1)\nabla L = (1, 1).
  2. Invert FF: F−1=diag(4,2)F^{-1} = \mathrm{diag}(4, 2).
  3. The natural direction is F−1∇L=(4×1,2×1)=(4,2)F^{-1}\nabla L = (4 \times 1, 2 \times 1) = (4, 2).
  4. With η=0.01\eta = 0.01, the plain step is −0.01×(1,1)=(−0.01,−0.01)-0.01 \times (1, 1) = (-0.01, -0.01).
  5. The natural step is −0.01×(4,2)=(−0.04,−0.02)-0.01 \times (4, 2) = (-0.04, -0.02).
  6. The natural step is larger in μ\mu and smaller in σ\sigma because μ\mu is the less sensitive parameter at this scale. Each parameter is rescaled by how much the distribution responds to it.
Example
3. A layer in a neural network (realistic)

A fully connected layer maps 500 inputs to 200 outputs, so its weight matrix has 500×200=100,000500 \times 200 = 100{,}000 entries (ignore biases). The full Fisher matrix for that layer would have (105)2=1010(10^5)^2 = 10^{10} entries.

K-FAC replaces the layer's block with a Kronecker product A⊗GA \otimes G. Here AA is a 500×500500 \times 500 matrix built from the layer's input activations, and GG is a 200×200200 \times 200 matrix built from the gradients at the layer's output. Each is much smaller:

  1. Count the entries of AA: 5002=250,000500^2 = 250{,}000.
  2. Count the entries of GG: 2002=40,000200^2 = 40{,}000.
  3. Total stored: 250,000+40,000=290,000250{,}000 + 40{,}000 = 290{,}000, against 101010^{10} for the full matrix.
  4. Inverting a product is the product of inverses, (A⊗G)−1=A−1⊗G−1(A \otimes G)^{-1} = A^{-1} \otimes G^{-1}, so the update for the weight matrix WW becomes G−1(∇WL)A−1G^{-1} (\nabla_W L) A^{-1}. This needs inverses of a 500×500500 \times 500 and a 200×200200 \times 200 matrix, not of a 105×10510^5 \times 10^5 matrix.
  5. The layer's update is then computed with two small matrix products per step, which is why the method is affordable at scale.

Try it: A layer maps 1000 inputs to 300 outputs. How many entries does the full Fisher matrix have, and how many does the K-FAC pair AA and GG store? Answer: the weights number 300,000300{,}000, so the full matrix has (3×105)2=9×1010(3 \times 10^5)^2 = 9 \times 10^{10} entries; K-FAC stores 10002+3002=1,000,000+90,000=1,090,0001000^2 + 300^2 = 1{,}000{,}000 + 90{,}000 = 1{,}090{,}000 entries.

Common mistakes and tradeoffs

It is tempting to think the natural gradient is the Hessian of the loss. In fact the Fisher matrix is an expectation under the model's own distribution and depends only on the model, while the Hessian depends on the loss and the data. They agree in one common case: when the loss is a negative log-likelihood and its curvature is averaged over the model's own distribution.

It is tempting to think the natural gradient always trains faster. In fact each step is more expensive, and it helps most when the sensitivity of the model varies a lot across parameters. A method that takes fewer steps can still lose on wall-clock time if the step is too costly.

It is tempting to think the method needs the exact inverse of a huge matrix. In fact practical versions use diagonal or block approximations such as K-FAC, and the approximation quality determines how much of the benefit survives.

When to use it: models that are probability distributions, reinforcement learning policies, and variational models, where the parameterisation is arbitrary and the step should not depend on it. Also deep networks where a block approximation is available.

When not to use it: very large models where no good approximation fits the budget. Plain stochastic gradient descent and adaptive methods such as Adam are cheaper and are the default for most large-scale training. The natural gradient is the principled reference point that those methods approximate.

History

Calculus on parameter spaces was well established long before anyone asked which geometry a learning rule should use. C. R. Rao's 1945 work made the Fisher information a measure of distance between models, and information geometry grew from that idea in the following decades.

In 1998 Shun-ichi Amari argued that learning should follow the natural gradient, because ordinary gradient descent depends on how the parameters happen to be written and can slow down badly on flat regions. The idea stayed mostly theoretical for years, mainly because the matrix inverse was too expensive for the models of the day.

Sham Kakade's natural policy gradient, in the early 2000s, brought the idea into reinforcement learning, where policies are naturally probability distributions. In 2015 Martens and Grosse introduced K-FAC, which made a practical approximation possible for deep networks, and TRPO used a closely related step with a KL limit to train policies more reliably. Both helped the idea spread from theory into training systems.

Recap

  • The ordinary gradient depends on how the parameters are labelled; the natural gradient does not.
  • The Fisher matrix measures how much each direction in parameter space changes the model's probabilities.
  • The natural step is the inverse Fisher matrix times the gradient, the steepest direction for a fixed KL distance.
  • Exact inverses are too expensive for large models, so approximations such as K-FAC are used in practice.
  • Read next: Kullback–Leibler Divergence, the distance this method is measured in, and Hessian Matrix, the curvature it is often confused with.

Check yourself

QuestionRecall: what does the Fisher information measure, in two equivalent ways?Show answer
It measures how sensitive the model's distribution is to its parameter. It is the average squared score, and equivalently the negative average curvature of the log-likelihood.
QuestionComputation: a coin model has theta equal to 0.2, the gradient is 0.4, and the learning rate is 0.1. What is the natural step size, and what is the new theta?Show answer
The Fisher information is 10.2×0.8=6.25\frac{1}{0.2 \times 0.8} = 6.25. The natural step is 0.1×0.4/6.25=0.00640.1 \times 0.4 / 6.25 = 0.0064, so the new value is 0.2−0.0064=0.19360.2 - 0.0064 = 0.1936.
QuestionWhy: why does the natural gradient not depend on how the parameters are labelled, while the ordinary gradient does?Show answer
The natural step is defined by how much the distributions change, measured with KL divergence. If you relabel the parameters, the set of distributions and the distances between them stay the same, so the natural step on the distributions is the same. The ordinary gradient measures change in the raw numbers, so relabelling changes it.
QuestionApplied: a team wants natural gradient updates for a network with ten million parameters. What is the obstacle, and what should they do?Show answer
The full Fisher matrix would have (107)2=1014(10^7)^2 = 10^{14} entries, which cannot be stored or inverted. They should use an approximation such as a diagonal Fisher, which is close to Adam-style scaling, or a block method such as K-FAC, or use an adaptive optimiser directly.

Sources