Natural gradient decent minimizes the loss function in distribution space with KL-divergence as metric, instead of the usual parameter space with Euclidean metric.

## Preliminary

### Gradient Decent

Assume that $L(θ)$ is a loss function with first-order continuous partial derivatives, where $θ∈R_{n}$. Now want to solve a unconstrained optimization problem:

$θmin L(θ)$

**Gradient descent** is an iterative optimization algorithm. It works by starting at a random point on the objective function and iteratively updating $θ$. This process is repeated until the minimum is found or the algorithm converges. Formally, in $(k+1)$th iteration, we have:

$θ_{(k+1)}=θ_{(k)}+ηv(1)$

where $η$ is step size and $v$is update direction. The first order Taylor series expansion of $L(θ_{(k+1)})$ at $θ_{(k)}$ is:

$L(θ_{(k+1)}) =L(θ_{(k)})+∇L(θ_{(k)})⋅(θ_{(k+1)}−θ_{(k)})+o(θ_{(k)})=L(θ_{(k)})+ηv⋅∇L(θ_{(k)})+o(θ_{(k)})≈L(θ_{(k)})+ηv⋅∇L(θ_{(k)}) $

We want to find a steepest descent direction around the local neighbourhood of $θ$ in the parameter space, that is to minimize:

$L(θ_{(k+1)})−L(θ_{(k)})=ηv⋅∇L(θ_{(k)})=η⋅∥v∥⋅∥∇L(θ_{(k)})∥⋅cos(α)$

where $α$ is the angle between $v$and $∇L(θ_{(k)})$. Obviously, when $α=−π$, i.e. when $v$and $∇L(θ_{(k)})$ are in the opposite directions, $cos(α)=−1$ and the loss decrease most greatly. This is why gradient decent moves in the direction of the negative gradient:

$v=−∥∇L(θ_{(k)})∥∇L(θ_{(k)}) $

Now we can write Eq. 1 as:

$θ_{(k+1)}=θ_{(k)}−∥∇L(θ_{(k)})∥η ⋅∇L(θ_{(k)})$

where $∥∇L(θ_{(k)})∥η $ is learning rate.

### KL Divergence

The **Kullback-Leibler divergence**, also known as the **relative entropy**, is a measure of the difference between current probability distribution $p$ and target distribution $q$, which is defined as:

$KL(p∥q)=∫p(x)gq(x)p(x) dx$

The KL divergence is zero if and only if the two distributions are equal. Note that KL divergence is non-symmetric, meaning that the KL divergence between $p$ and $q$ is not necessarily equal to that between $q$ and $p$.

### Fisher Information Matrix

I suggest having a look at this great article. To be short, the **Fisher Information Matrix** is:

the second moment of the first-order derivative of the log-likelihood function:

$F=E_{p(x∣θ)}[∇gp(x∣θ)∇gp(x∣θ)_{T}]$

the negative expectation of the Hessian matrix of the log-likelihood function (proof):

$F=−E_{p(x∣θ)}[∂_{θ}∂_{θ_{T}}∂_{2} gp(x∣θ)]$

### KL Divergence & Fisher Information

Let $d→0$, we have:

$KL(p(x∣θ)∥p(x∣θ+d))≈21 d_{T}Fd$

## Proof

For convenience, we denote $p(x∣θ)$ and $p(x∣θ+d)$ as $p(θ)$ and $p(θ+d)$, respectively.

$KL(p(θ)∥p(θ+d)) =∫p(θ)gp(θ+d)p(θ) dx=E_{p(θ)}[gp(θ+d)p(θ) ]=E_{p(θ)}[gp(θ)]−E_{p(θ)}[logp(θ+d)]≈E_{p(θ)}[gp(θ)]−second order Taylor expansionE_{p(θ)}[logp(θ)+∇logp(θ)d+21 d_{T}∇_{2}logp(θ)d] =−E_{p(θ)}[∇gp(θ)d]−E_{p(θ)}[21 d_{T}∇_{2}gp(θ)d]=−[∫_{θ}p(θ)p(θ)1 ∇p(θ)dθ]d−21 d_{T}E_{p(θ)}[∇_{2}gp(θ)]d=−[∇∫_{θ}p(θ)dθ]d−21 d_{T}E_{p(θ)}[∇_{2}gp(θ)]d=−21 d_{T}=−FE_{p(θ)}[∇_{2}gp(θ)] d=21 d_{T}Fd $

Which means the Fisher Information Matrix $F$ defines the local curvature in distribution space for which KL-divergence is the metric.

### Riemannian manifold

#### Manifold

A manifold is a topological space sharing the local properties of Euclidean spaces. Every point on a manifold has a small neighborhood around it that can be locally approximated by a tangent plane, which means that the curvature of this neighborhood is approximately zero. This allows us to use the Euclidean metric, which is based on the properties of flat space, to measure distance within this small neighborhood. To help your understanding, people on earth may experience their surroundings as being flat, but they are unable to perceive the curvature of the earth due to its large size.

More formally: A manifold $M$ of dimension $n$ is a topological space, such that every point $x∈M$ has a neighbourhood which is homeomorphic to an open set in Euclidean space $R_{n}$. This open set in Euclidean space is called **tangent space**, refered as $T_{x}M$.

#### Riemannian Metric

The distance between two points in an Euclidean space can be easily determined by taking the modulusof the vector connecting the points. However, manifolds are not linear spaces, so we need to use alternative methods to calculate lengths on a manifold. One possible approach is to consider a continuous, differentiable curve, represented by $γ:[a,b]→M$, on the manifold and compute the integral of the distance differential at each point along curve $γ$:

$L(γ)=∫_{a}∥γ_{′}(x)∥dx$

Thus for each point $γ(x)$, we have to define a notion of distance in the tangent space at that point. We then use the notion to calculate the modulus $∥γ_{′}(x)∥$ of the tangent vector $γ_{′}(x)=∂x∂ γ(x)$ at the point and add up all of $∥γ_{′}(x)∥$ to obtain the total length of the curve.

To calculate $∥γ_{′}(x)∥$:

$∥γ_{′}(x)∥_{2}=⟨γ_{′}(x),γ_{′}(x)⟩=g_{γ(x)}(γ_{′}(x),γ_{′}(x))$

The square of the modulus of a vector, also known as the Euclidean norm or the $ℓ_{2}$ norm, is equal to the inner product of the vector with itself. This means that $g_{x}:T_{x}M×T_{x}M→R$ defines a **metric**, which is a way of measuring distance, over a tangent space. A metric that varies smoothly with respect to a point on a manifold is known as a **Riemannian metric**, and a manifold equipped with a Riemannian metric is called a **Riemannian manifold**.

As explained here (page 4):

Roughly, a Riemannian manifold $M$ is a smooth set with a smoothly-varying inner product on the tangent spaces.

Formally, for each $x∈M$，a Riemannian metric $g=g_{x}$ satisfies:

- $g(u,v)=g(v,u)$ for all $u,v∈T_{x}M$
- $g(u,u)≥0$ for all $u∈T_{x}M$
- $g(u,u)=0$ if and only if $u=0$

## Natural Gradient Decent

### Constrained Optimization

Let’s start with looking at **natural gradient decent** from aspect of constrained optimization. In traditional gradient decent, the constrained optimization problem we want to solve is:

$dmin L(θ+d)s.t.∥d∥≤ϵ $

where the distance in parameter space is contrained and can be calculated using Euclidean metric.

As mentioned before, the steepest descent direction is the direction of the negative gradient:

$−∥∇L(θ)∥∇L(θ) =ϵ→0lim ϵ1 gds.t.∥d∥≤ϵmin L(θ+d)$

When using gradient descent, the distribution of the parameters may change as the optimization process progresses. However, it is also important to ensure that the amount of change in the distribution is controlled, as large changes can lead to instability in the model. The Euclidean distance, which is based on the properties of flat space, may not be an appropriate measure of the amount of change in the distribution. Therefore, natural gradient decent works in **distribution space** and uses KL divergence to compare the current distribution of parameters $p(x∣θ)$ with the target distribution $p(x∣θ+d)$. Now the constraint becomes:

$s.t.KL(p(x∣θ)∥p(x∣θ+d))≤ϵ$

We apply the Lagrange multiplier method to it:

$d_{∗} =gdmin L(θ+d)+λ(KL(p(x∣θ)∥p(x∣θ+d))−ϵ)≈gdmin first order Taylor expansionL(θ)+∇L(θ)_{T}d +second order Taylor expansion21 λd_{T}Fd −λϵ $

To solve this minimization, we set its derivative to zero:

$0λFdd =∂d∂ [L(θ)+∇L(θ)_{T}d+21 λd_{T}Fd−λϵ]=∇L(θ)+λFd=−∇L(θ)=−λ1 F_{−1}∇L(θ) $

Finally, the optimal descent direction is $∇~L(θ)=F_{−1}∇L(θ)$ (constant factor can be absorbed into the learning rate), called **natural gradient**.

### Riemannian Manifold

Now we consider optimizing the objective function on a manifold. We can easily recognize that the descent direction depends on how to calculate $∥d∥$, i.e., what’s the metric on the manifold.

The tranditional gradient decent works on parameter space (a Euclidean space), of which the metric is Euclidean metric. The natural gradient descent operates in distribution space (a Riemannian manifold), in which a point, represented by $p(x∣θ)$, can be thought of as a parameterized probability distribution. When the parameter $θ$ changes to $θ+d$, the distance between $p(x∣θ)$ and $p(x∣θ+d)$ is $21 d_{T}Fd$. It can be seen that the Fisher information matrix $F$ serves as the Riemannian metric on this Riemannian manifold.

The Fisher information matrix reflects the local curvature of the likelihood probability distribution space, which means that it encodes information about how much the probability distribution changes as the parameters vary. By using the Fisher information matrix as a measure, we can obtain the descent direction that takes into account the curvature of the probability distribution space. This is important because the larger the curvature, the smaller the range of parameter values that can be used to maintain a given likelihood. Natural gradient descent ensures that the optimization process respects the underlying geometry of the probability distribution space and avoids making large, unstable changes to the parameters.

## References

- Natural Gradient Descent.
*Agustinus Kristiadi*. - Differential Geometry.
*Ben Andrews*. Australian National University. - Differential Geometry.
*Nigel Hitchin*. Oxford University. - Riemannian Metrics.
*Claudio Gorodski*. University of São Paulo. - Geometric Deep Learning: Going beyond Euclidean Data. IEEE Signal Processing Magazine 2017.
*Michael M. Bronstein, et al*.