# A Geometric Interpretation of Stochastic Gradient Descent Using Diffusion Metrics

^{1}

^{2}

^{3}

^{*}

Next Article in Journal

Next Article in Special Issue

Next Article in Special Issue

Previous Article in Journal

Previous Article in Special Issue

Previous Article in Special Issue

Dipartimento di Matematica, piazza Porta San Donato 5, University of Bologna, 40126 Bologna, Italy

Department of Electrical and Systems Engineering, University of Pennsylvania, Philadelphia, PA 19104, USA

Computer Science Department, University of California, Los Angeles, CA 90095, USA

Author to whom correspondence should be addressed.

Received: 30 November 2019 / Revised: 8 January 2020 / Accepted: 10 January 2020 / Published: 15 January 2020

(This article belongs to the Special Issue The Information Bottleneck in Deep Learning)

This paper is a step towards developing a geometric understanding of a popular algorithm for training deep neural networks named stochastic gradient descent (SGD). We built upon a recent result which observed that the noise in SGD while training typical networks is highly non-isotropic. That motivated a deterministic model in which the trajectories of our dynamical systems are described via geodesics of a family of metrics arising from a certain diffusion matrix; namely, the covariance of the stochastic gradients in SGD. Our model is analogous to models in general relativity: the role of the electromagnetic field in the latter is played by the gradient of the loss function of a deep network in the former.

Deep neural networks are high-dimensional machine learning models that have demonstrated impressive performance on a number of challenging tasks in computer vision, natural language processing and reinforcement learning [1,2]. These models are typically trained to minimize the misprediction error compared to large amounts of human-annotated data. A large number of diverse models with varying properties are prevalent in these application domains. Despite this diversity, stochastic gradient descent (SGD) is the gold standard for training deep neural networks. It has been shown to obtain good generalization performance; i.e., to train a model that performs well on new data, across a wide range of applications. In spite of this popularity and efficacy, a precise understanding of SGD for deep learning remains elusive.

This paper develops a geometric understanding of stochastic gradient descent. We build upon the work of [3], wherein the authors model the dynamics of SGD as a stochastic differential equation with state-dependent Gaussian noise. We interpret the covariance of this noise, called the diffusion matrix henceforth, as a metric on the parameter space. Our result provides a deterministic Equation (10) that can be compared to SGD near equilibrium points Equation (1). We write the diffusion matrix $D\left(x\right)$ in the form Equation (3) to show how it fundamentally captures the anisotropy of the dynamical system underlying SGD. This clarifies how $D\left(x\right)$ is one of the key factors that differentiates steady-state solutions of SGD from those of ordinary gradient descent GD (see comparison in [3,4,5]). Using the diffusion matrix, we then define a family of metrics on the parameter space that we call diffusion metrics. We then take the Einstein equation describing the geodesic on a Riemannian manifold, for the motion of a particle subject to a gravitational and electromagnetic field. We replace the electromagnetic force by the ordinary gradient while gravity is taken into account using the diffusion metric itself. After some mild hypotheses on the architecture of the neural network, we obtain the result that geodesics with respect to this equation correspond precisely to the evolution of a dynamical system, which is not subject to Euclidean gradient descent but to relativistic gradient descent (RGD) with respect to the family of diffusion metrics.

In the end, we obtain Equation (10), which is along the same vein as natural gradient descent in [6], but whose significance is much deeper in the context of SGD, since it stems from the anisotropy of the gradients with respect to the various parameters. This anisotropy encodes the difference between the dynamics of GD and those of SGD. We also compare our result with the ones in [3] and show them to be perfectly compatible. In the end we provide Appendix A for the reader convenience, with a quick review of some key facts of Riemannian geometry.

Stochastic gradient descent performs an update of the weights x of a neural network, replacing the ordinary gradient of the loss function $f=\frac{1}{N}{\sum}_{i=1}^{N}{f}_{i}$ with ${\nabla}_{\mathcal{B}}f$:
where $dx$ represents the continuous version of the weight update at step j: ${x}_{j+1}={x}_{j}-\eta {\nabla}_{\mathcal{B}}f\left({x}_{j}\right)$, with the learning rate $\eta $ incorporated into the expression of ${\nabla}_{\mathcal{B}}f$, and $\mathcal{B}$ is the mini-batch. In the expression of the loss function $f=\frac{1}{N}{\sum}_{i=1}^{N}{f}_{i}$, ${f}_{i}$ is the loss relative to the i-th element in our dataset $\mathsf{\Sigma}$ of size $|\mathsf{\Sigma}|=N$. We assume that weights belong to a compact subset $\mathsf{\Omega}\subset {\mathbb{R}}^{d}$ and that the ${f}_{i}s$ satisfy suitable regularity conditions (see [3] Section 2 for more details).

$$dx=-{\nabla}_{\mathcal{B}}fdt,\phantom{\rule{2.em}{0ex}}{\nabla}_{\mathcal{B}}f=\frac{1}{|\mathcal{B}|}\sum _{i\in \mathcal{B}}\nabla {f}_{i},$$

We define the diffusion matrix as the product of the size of the mini-batch $|\mathcal{B}|$ and the variance of ${\nabla}_{\mathcal{B}}f$, viewed as a random variable, $\varphi :\mathsf{\Sigma}\u27f6{\mathbb{R}}^{d}$, $\varphi \left({z}_{i}\right)=\nabla {f}_{i}$:

$$D\left(x\right)=\mathbb{E}\left[(\varphi -\mathbb{E}\left[\varphi \right]){(\varphi -\mathbb{E}\left[\varphi \right])}^{t}\right]$$

Notice that $D\left(x\right)\in {\mathbb{R}}^{d\times d}$ and does not depend on the size of the mini-batch; it only depends on the weights x, loss function f and the dataset $\mathsf{\Sigma}$. With a direct calculation one can show that:
where:
and $\langle ,\rangle $ is the euclidean scalar product. In fact:
which gives:

$$\begin{array}{cc}\hfill D& =\frac{1}{N}{\sum}_{k}(\nabla {f}_{k}){(\nabla {f}_{k})}^{t}-(\nabla f){(\nabla f)}^{t}=\frac{1}{{N}^{2}}\left(\langle {\partial}_{r}\widehat{f},{\partial}_{s}\widehat{f}\rangle \right)\hfill \end{array}$$

$$\widehat{f}=({f}_{1}-{f}_{2},{f}_{1}-{f}_{3},\cdots ,{f}_{N-1}-{f}_{N})\in {\mathbb{R}}^{N(N-1)/2}$$

$$\begin{array}{cc}\hfill {D}_{rs}& =\frac{1}{N}{\sum}_{k=1}^{N}{\partial}_{r}{f}_{k}\phantom{\rule{0.166667em}{0ex}}{\partial}_{s}{f}_{k}-\frac{1}{{N}^{2}}\sum _{i,j=1}^{N}{\partial}_{r}{f}_{i}\phantom{\rule{0.166667em}{0ex}}{\partial}_{s}{f}_{j}\hfill \\ & =\frac{1}{{N}^{2}}[N({\partial}_{r}{f}_{1}\phantom{\rule{0.166667em}{0ex}}{\partial}_{s}{f}_{1}+\cdots +{\partial}_{r}{f}_{N}\phantom{\rule{0.166667em}{0ex}}{\partial}_{s}{f}_{N})+\hfill \\ & -({\partial}_{r}{f}_{1}\phantom{\rule{0.166667em}{0ex}}{\partial}_{s}{f}_{1}+{\partial}_{r}{f}_{1}\phantom{\rule{0.166667em}{0ex}}{\partial}_{s}{f}_{2}+\cdots +{\partial}_{r}{f}_{N}\phantom{\rule{0.166667em}{0ex}}{\partial}_{s}{f}_{N})]=\hfill \\ & =\frac{1}{{N}^{2}}[(N-1){\partial}_{r}{f}_{1}\phantom{\rule{0.166667em}{0ex}}{\partial}_{s}{f}_{1}-{\partial}_{r}{f}_{1}\phantom{\rule{0.166667em}{0ex}}{\partial}_{s}{f}_{2}-\cdots -{\partial}_{r}{f}_{1}\phantom{\rule{0.166667em}{0ex}}{\partial}_{s}{f}_{N}+\hfill \\ & -{\partial}_{r}{f}_{2}\phantom{\rule{0.166667em}{0ex}}{\partial}_{s}{f}_{1}+(N-1){\partial}_{r}{f}_{2}\phantom{\rule{0.166667em}{0ex}}{\partial}_{s}{f}_{2}-\cdots -{\partial}_{r}{f}_{2}\phantom{\rule{0.166667em}{0ex}}{\partial}_{s}{f}_{N}+\cdots \hfill \\ & -{\partial}_{r}{f}_{N}\phantom{\rule{0.166667em}{0ex}}{\partial}_{s}{f}_{1}-{\partial}_{r}{f}_{N}\phantom{\rule{0.166667em}{0ex}}{\partial}_{s}{f}_{2}+\cdots +(N-1){\partial}_{r}{f}_{N}\phantom{\rule{0.166667em}{0ex}}{\partial}_{s}{f}_{N}]\hfill \end{array}$$

$$\begin{array}{cc}\hfill {D}_{rs}& =\frac{1}{{N}^{2}}[({\partial}_{r}{f}_{1}-{\partial}_{r}{f}_{2})({\partial}_{s}{f}_{1}-{\partial}_{s}{f}_{2})+({\partial}_{r}{f}_{1}-{\partial}_{r}{f}_{3})({\partial}_{s}{f}_{1}-{\partial}_{s}{f}_{3})+\cdots \hfill \\ & +({\partial}_{r}{f}_{1}-{\partial}_{r}{f}_{N})({\partial}_{s}{f}_{1}-{\partial}_{s}{f}_{N})+({\partial}_{r}{f}_{2}-{\partial}_{r}{f}_{3})({\partial}_{s}{f}_{2}-{\partial}_{s}{f}_{3})+\cdots \hfill \\ & +({\partial}_{r}{f}_{N-1}-{\partial}_{r}{f}_{N})({\partial}_{s}{f}_{N-1}-{\partial}_{s}{f}_{N})=\frac{1}{{N}^{2}}\left(\langle {\partial}_{r}\widehat{f},{\partial}_{s}\widehat{f}\rangle \right).\hfill \end{array}$$

The diffusion matrix measures effectively the anisotropy of our data: $D=0$ if and only if ${\partial}_{r}\left({f}_{i}\right)={\partial}_{r}\left({f}_{j}\right)$ for all $r=1,\cdots ,d$ and $i,j=1,\cdots ,N$. In other words, the diffusion matrix measures how the loss of each datum depends, at first order, on the weights in a different way with respect to the loss of each of the other data-points. So, it tells us how much we should expect the SGD dynamics to differ from the GD one. Notice that the expression (Equation (3)) gives us immediately a bound on the rank of D; namely, $\mathrm{rk}\left(D\right)\le N-1$.

The Table 1 suggests that in many algorithms currently available, the diffusion matrix has low rank; hence, it is singular; this just by comparing the size d of D and its rank which bound by N. This fact turns out to be very important in the construction of the diffusion metrics, as we will see below.

The evolution of a dynamical system in general relativity takes place along the geodesics according to the metric imposed on the Minkowski space by the presence of gravitational masses. The equation for such geodesics, once Einstein’s equation is solved, is:
where ${\mathsf{\Gamma}}_{\rho \sigma}^{\mu}$ are the Christoffel symbols for the Levi–Civita connection:
and $\frac{q}{m}{F}_{\nu}^{\mu}$ is a term regarding an external force; e.g., one coming from an electromagnetic field.

$$\frac{{d}^{2}{x}^{\mu}}{d{t}^{2}}\phantom{\rule{0.166667em}{0ex}}+\phantom{\rule{0.166667em}{0ex}}{\mathsf{\Gamma}}_{\rho \sigma}^{\mu}\frac{d{x}^{\rho}}{dt}\frac{d{x}^{\sigma}}{dt}=\frac{q}{m}{F}_{\nu}^{\mu}\frac{d{x}^{\nu}}{dt},$$

$${\mathsf{\Gamma}}_{uv}^{w}=\frac{1}{2}{g}^{wz}\left({\partial}_{u}{g}_{vz}-{\partial}_{z}{g}_{uv}+{\partial}_{v}{g}_{uz}\right)$$

If we take the time derivative of the differential equation underlying the ordinary (i.e., non stochastic) gradient descent:
and compare with Equation (4), observe that $-\frac{d}{dt}\phantom{\rule{0.166667em}{0ex}}{\partial}_{\mu}f$ effectively replaces the force term $(q/m){F}_{\nu}^{\mu}\frac{d{x}^{\nu}}{dt}$. Hence, the geodesic equation Equation (4) models the ordinary GD equation if we take a constant metric and replace the force term with the gradient of the loss; furthermore, this corresponds to the condition $D=0$ in SGD dynamics Equation (1).

$$\frac{{d}^{2}{x}^{\mu}}{d{t}^{2}}\phantom{\rule{0.166667em}{0ex}}=-\frac{d}{dt}\phantom{\rule{0.166667em}{0ex}}{\partial}_{\mu}f$$

This suggests that one may define a metric dependent on the diffusion matrix; this metric should become constant when $D=0$. As a side remark, notice that since D is singular in many important practical applications (see Table 1), it is not reasonable to use it to define the metric itself. On the other hand, since D measures the anisotropy of the weight space, it is reasonable to employ it to perturb the euclidean metric. So the stochastic nature of the dynamical system ruled by the SGD is replaced by a perturbation of the dynamics for the ordinary gradient descent. As an analogy, the presence of (small) masses in space, in the weak field approximation (see [7]) of general relativity, generates gravity; this motivates our (small) deformation of the euclidean metric using the diffusion matrix.

At each point $x\in \mathsf{\Omega}$, we define a metric called diffusion metric as
with $\epsilon \left(x\right)<1/{M}_{x}$, where ${M}_{x}=\mathrm{max}\{{\lambda}_{k}:\phantom{\rule{4pt}{0ex}}{\lambda}_{k}\phantom{\rule{4pt}{0ex}}\mathrm{is}\phantom{\rule{4pt}{0ex}}\mathrm{an}\phantom{\rule{4pt}{0ex}}\mathrm{eigenvalue}\phantom{\rule{4pt}{0ex}}\mathrm{of}\phantom{\rule{4pt}{0ex}}D\left(x\right)\}$. This ensures that g is non-singular at each $x\in \mathsf{\Omega}$. We have, thus, defined a family of metrics that depend on the real parameter $\epsilon $. We expect this model to approximate the solution to the Fokker–Planck equation when the parameter ${\beta}^{-1}$, whose interpretation is related with the temperature, is very small (see [3] for the notation and more details).

$$g\left(x\right)=\mathrm{id}+\epsilon \left(x\right)D\left(x\right)$$

Notice that our heuristic hypothesis on $\epsilon $ allows us to make the so called weak field approximation (see [7]):

$${g}^{-1}=\mathrm{id}-\epsilon D\left(x\right).$$

Hence, we have the following expression for the Christoffel’s symbols (in this approximation we discard $\mathcal{O}\left({\epsilon}^{2}\right)$):
where d_{ij} are the coefficients of D, and δ_{wz} is the Kronecker delta.

$${\mathsf{\Gamma}}_{uv}^{w}=\frac{1}{2}\sum _{z}({\delta}_{wz}-{\epsilon}_{wz}^{d})\phantom{\rule{0.166667em}{0ex}}{\epsilon}^{\phantom{\rule{0.166667em}{0ex}}}\left({\partial}_{u}{d}_{vz}-{\partial}_{z}{d}_{uv}+{\partial}_{v}{d}_{uz}\right)=\frac{\epsilon}{2}\left.({\partial}_{u}{d}_{vw}-{\partial}_{w}{d}_{uv}+{\partial}_{v}{d}_{uw}\right)$$

Let us now compute the Christoffel’s symbols and then substitute them into the geodesic equation given by Equation (4).

$$\begin{array}{cc}\hfill {\mathsf{\Gamma}}_{ij}^{k}& =\frac{\epsilon}{2{N}^{2}}[\langle {\partial}_{i}{\partial}_{j}\widehat{f},{\partial}_{k}\widehat{f}\rangle +\langle {\partial}_{j}\widehat{f},{\partial}_{i}{\partial}_{k}\widehat{f}\rangle -\langle {\partial}_{i}{\partial}_{k}\widehat{f},{\partial}_{j}\widehat{f}\rangle -\langle {\partial}_{i}\widehat{f},{\partial}_{k}{\partial}_{j}\widehat{f}\rangle \hfill \\ & +\langle {\partial}_{j}{\partial}_{k}\widehat{f},{\partial}_{i}\widehat{f}\rangle +\langle {\partial}_{k}\widehat{f},{\partial}_{i}{\partial}_{j}\widehat{f}\rangle ]=\frac{\epsilon}{{N}^{2}}\langle {\partial}_{i}{\partial}_{j}\widehat{f},{\partial}_{k}\widehat{f}\rangle .\hfill \end{array}$$

Let us substitute in Equation (4) (writing the sum now):

$$\frac{{d}^{2}{x}^{k}}{d{t}^{2}}\phantom{\rule{0.166667em}{0ex}}+\phantom{\rule{0.166667em}{0ex}}\frac{\epsilon}{{N}^{2}}\sum _{i,j}\langle {\partial}_{i}{\partial}_{j}\widehat{f},{\partial}_{k}\widehat{f}\rangle \frac{d{x}^{i}}{dt}\frac{d{x}^{j}}{dt}=\frac{d}{dt}{\partial}_{k}f.$$

Let us concentrate on the expression:

$$\begin{array}{cc}\hfill \frac{\epsilon}{{N}^{2}}{\sum}_{i,j}\langle {\partial}_{i}{\partial}_{j}\widehat{f},{\partial}_{k}\widehat{f}\rangle \frac{d{x}^{i}}{dt}\frac{d{x}^{j}}{dt}& =\frac{\epsilon}{{N}^{2}}{\sum}_{i,j,\alpha}{\partial}_{i}{\partial}_{j}{\widehat{f}}_{\alpha}\phantom{\rule{0.166667em}{0ex}}{\partial}_{k}{\widehat{f}}_{\alpha}\frac{d{x}^{i}}{dt}\frac{d{x}^{j}}{dt}\hfill \\ & =\frac{\epsilon}{{N}^{2}}{\sum}_{\alpha}\frac{{d}^{2}{\widehat{f}}_{\alpha}}{d{t}^{2}}{\partial}_{k}{\widehat{f}}_{\alpha}.\hfill \end{array}$$

Now, we take the integral in dt (we compute the parts twice):

$$\begin{array}{cc}\hfill \frac{\epsilon}{{N}^{2}}\int {\sum}_{\alpha}\frac{{d}^{2}{\widehat{f}}_{\alpha}}{d{t}^{2}}{\partial}_{k}{\widehat{f}}_{\alpha}\phantom{\rule{0.166667em}{0ex}}dt& =\frac{\epsilon}{{N}^{2}}{\sum}_{\alpha}\left[\frac{d{\widehat{f}}_{\alpha}}{dt}{\partial}_{k}{\widehat{f}}_{\alpha}-\int \frac{d{\widehat{f}}_{\alpha}}{dt}\frac{{\partial}_{k}{\widehat{f}}_{\alpha}}{dt}\phantom{\rule{0.166667em}{0ex}}dt\right]\hfill \\ & =\frac{\epsilon}{{N}^{2}}{\sum}_{\alpha}\left[\frac{d{\widehat{f}}_{\alpha}}{dt}{\partial}_{k}{\widehat{f}}_{\alpha}-{\widehat{f}}_{\alpha}\frac{d}{dt}{\partial}_{k}{\widehat{f}}_{\alpha}+\int {\widehat{f}}_{\alpha}\frac{{d}^{2}}{d{t}^{2}}{\partial}_{k}{\widehat{f}}_{\alpha}\phantom{\rule{0.166667em}{0ex}}dt\right].\hfill \end{array}$$

Notice that, in many practical applications we have:
because ${\partial}_{i}{\partial}_{j}{\partial}_{k}\widehat{f}=0.$

$$\frac{{d}^{2}}{d{t}^{2}}{\partial}_{k}{\widehat{f}}_{\alpha}=0$$

Hence

$$\begin{array}{cc}\hfill \frac{\epsilon}{{N}^{2}}\int {\sum}_{\alpha}\frac{{d}^{2}{\widehat{f}}_{\alpha}}{d{t}^{2}}{\partial}_{k}{\widehat{f}}_{\alpha}\phantom{\rule{0.166667em}{0ex}}dt& =\frac{\epsilon}{{N}^{2}}{\sum}_{\alpha ,\ell}\left[{\partial}_{\ell}{\widehat{f}}_{\alpha}\frac{d{x}^{\ell}}{dt}{\partial}_{k}{\widehat{f}}_{\alpha}-{\widehat{f}}_{\alpha}\frac{d}{dt}{\partial}_{k}{\widehat{f}}_{\alpha}\right]\hfill \\ & =\epsilon {\sum}_{\ell}{d}_{k,\ell}\frac{d{x}^{\ell}}{dt}-\frac{\epsilon}{{N}^{2}}{\sum}_{\alpha}{\widehat{f}}_{\alpha}\frac{d}{dt}{\partial}_{k}{\widehat{f}}_{\alpha}.\hfill \end{array}$$

We now substitute the obtained expression into the Equation (8), taking the integral in dt:

$$\frac{d{x}^{k}}{dt}\phantom{\rule{0.166667em}{0ex}}+\epsilon \sum _{\ell}{d}_{k,\ell}\frac{d{x}^{\ell}}{dt}-\frac{\epsilon}{{N}^{2}}\sum _{\alpha}{\widehat{f}}_{\alpha}\frac{d}{dt}{\partial}_{k}{\widehat{f}}_{\alpha}=-{\partial}_{k}f.$$

We may assume $\frac{\epsilon}{{N}^{2}}$ very small, as motivated by Equation (1); hence, discard this term. Writing the equation into vector form, we have:

$$\frac{dx}{dt}+\epsilon D\frac{dx}{dt}=-\nabla f.$$

By the weak field approximation ${(I+\epsilon D)}^{-1}\cong (I-\epsilon D)$, we can write:
where ${\nabla}_{D}f$ is the gradient computed according to the diffusion metric Equation (6).

$$\frac{dx}{dt}=-(I-{\epsilon}^{D})\nabla f=-{\nabla}_{D}f,$$

We can summarize our result as follows: the SGD equation Equation (1) can be replaced, provided the approximation Equation (9) holds, by the deterministic equation Equation (10), where the dynamical system evolves with respect to the gradient computed according to the diffusion metric Equation (6).

We now want to compare our result Equation (10) with [3] Section 1, in order to understand how the steady state solutions of Equation (10) compare to the SGD steady state solutions described by Equation (1). In [3], the authors regard SGD as minimizing the function Φ instead of our loss f. Let us focus on (8) in [3], where the relation between f and Φ is discussed. In our case, we take ∇Φ = ∇_{D}f so that Equation (11) becomes
where $\tilde{D}\left(x\right)=(I+\epsilon D\left(x\right))$ is the diffusion metric. If the term D(x) in (8) in [3] is spelled out as our $\tilde{D}\left(x\right)$, we can write such equation as:

$$-\nabla f\left(x\right)+\tilde{D}\left(x\right)\nabla \mathsf{\Phi}\left(x\right)=0,$$

$$j\left(x\right)=-\nabla f\left(x\right)+\tilde{D}\left(x\right)\nabla \mathsf{\Phi}\left(x\right)-{\beta}^{-1}\nabla \xb7\tilde{D}\left(x\right).$$

The general relativity (GR) model helps to provide a deterministic approach the evolution of the dynamical system described by SGD, through the use of the diffusion metric accounting for the anisotropy of the system. Our results are compatible with [3]; moreover, they give GD for an isotropic system. We plan to explore deep neural networks mixing our GR model with energy models in a forthcoming paper (see also [9]). This will provide new geometric insight to the theory.

Conceptualization, R.F. and P.C.; Investigation, R.F. and P.C.; Methodology, R.F.; Supervision, S.S.; Writing and original draft, R.F.; Writing and review editing, P.C. All authors have read and agreed to the published version of the manuscript.

This research was funded by MSCA EU project GHAIA grant number 777822.

The authors wish to thank A. Achille and F. Faglioni for many illuminating discussions.

The authors declare no conflict of interest.

We collected a few well known facts of Riemannian geometry, and invite the reader to consult [10] for more details.

In Riemannian geometry, we define a metric g on a smooth manifold M, as a smooth assignment $p\mapsto {g}_{p}$, which gives, for each $p\in M$, a (non degenerate) scalar product on ${T}_{p}\left(M\right)$, the tangent space of M at p. Usually, this scalar product is assumed to be a positive definite; however, for general relativity, it is necessary to drop this assumption, so that we speak of a pseudometric, because our main example is the Minkowski metric. To ease the terminology, we say "metric" to include this more general setting as well.

Once a metric is given, we say that M is a Riemannian manifold. In local coordinates, ${x}^{1},\dots ,{x}^{n}$, we express the metric using 1-forms:
where
is a basis of the tangent space ${T}_{p}M$.

$$g=\sum _{i,j}{g}_{ij}\phantom{\rule{0.166667em}{0ex}}\mathrm{d}{x}^{i}\otimes \mathrm{d}{x}^{j}.$$

$$g}_{ij}{|}_{p}:={g}_{p}\left({\left.\frac{\partial}{\partial {x}^{i}}\right|}_{p},{\left.\frac{\partial}{\partial {x}^{j}}\right|}_{p}\right)\phantom{\rule{2.em}{0ex}}\mathrm{and}\phantom{\rule{2.em}{0ex}}\left\{\frac{\partial}{\partial {x}^{1}}{{|}_{p},\cdots ,\frac{\partial}{\partial {x}^{n}}|}_{p}\right\$$

For example ${\mathbb{R}}^{n}$, identified with its tangent space at every point, has a canonical or standard metric given by:

$${g}_{p}^{\mathrm{can}}:{T}_{p}{\mathbb{R}}^{n}\times {T}_{p}{\mathbb{R}}^{n}\u27f6\mathbf{R},\phantom{\rule{2.em}{0ex}}\left(\sum _{i}{a}_{i}\frac{\partial}{\partial {x}^{i}},\sum _{j}{b}_{j}\frac{\partial}{\partial {x}^{j}}\right)\u27fc\sum _{i}{a}_{i}{b}_{i}.$$

Here, ${g}_{ij}^{\mathrm{can}}={\delta}_{ij}$.

Usually, we drop the ∑ symbol, following Einstein’s convention.

An affine connection ∇ on a smooth manifold M is an bilinear map $(X,Y)\mapsto {\nabla}_{X}Y$ associating with a pair of vector fields $X,Y$ on M another vector field ${\nabla}_{X}Y$, satisfying:

- ${\nabla}_{fX}Y=f{\nabla}_{X}Y$ for all functions f on M;
- ${\nabla}_{X}\left(fY\right)=df\left(X\right)Y+f{\nabla}_{X}Y$.

Once this definition is given, it is possible to define ∇ on tensors of every order.

On a Riemannian manifold we have a unique affine connection, the Levi–Civita connection ∇, which is torsion free and preserves the metric; i.e., $\nabla g=0$. In local coordinates the components of the connection are called the Christoffel symbols:

$${\nabla}_{\frac{\partial}{\partial {x}^{i}}}\frac{\partial}{\partial {x}^{j}}={\mathsf{\Gamma}}_{ij}^{k}\frac{\partial}{\partial {x}^{k}}.$$

By the above -mentioned uniqueness, the ${\mathsf{\Gamma}}_{ij}^{k}$s are expressed in terms of the metric components ${g}_{ij}$:
where as usual, ${g}^{ij}$ are the coefficients of the dual metric tensor; i.e., the entries of the inverse of the matrix $\left({g}_{kl}\right)$. The torsion freeness is equivalent to the symmetry

$${\mathsf{\Gamma}}_{jk}^{l}={\textstyle \frac{1}{2}}{g}^{lr}\left({\partial}_{k}{g}_{rj}+{\partial}_{j}{g}_{rk}-{\partial}_{r}{g}_{jk}\right)},$$

$${\mathsf{\Gamma}}_{jk}^{l}={\mathsf{\Gamma}}_{kj}^{l}.$$

In ${\mathbb{R}}^{n}$, the gradient of a scalar function f is the vector field characterized by the property: $\mathrm{grad}\left(f\right)\xb7v={D}_{v}$ (we shall denote it with $\nabla \left(f\right)$ so that no confusion arises). In other words, its scalar product (in the euclidean metric) with a tangent vector v gives the directional derivative of f along v. When M is a Riemannian manifold with metric g, the gradient of a function f on M is defined in the same way, except that the scalar product is now given by g. So, in local coordinates, we have:
Notice that when ${g}_{ij}={\delta}_{ij}$, we retrieve the usual definition in ${\mathbb{R}}^{n}$.

$${\nabla}_{g}f=\frac{\partial f}{\partial {x}^{i}}{g}^{ij}\frac{\partial}{\partial {x}^{j}}.$$

We end our short summary of the key concepts, with the notion of geodesic.

A geodesic $\gamma $ on a smooth manifold M with an affine connection ∇ is a curve defined by the following equation:

$${\nabla}_{\dot{\gamma}}\dot{\gamma}=0$$

Geometrically, this expresses the fact that the parallel transport, given by ∇, along the curve $\gamma $ preserves any tangent vector to the curve. In local coordinates this becomes:

$$\frac{{d}^{2}{\gamma}^{\lambda}}{d{t}^{2}}+{\mathsf{\Gamma}}_{\mu \nu}^{\lambda}\frac{d{\gamma}^{\mu}}{dt}\frac{d{\gamma}^{\nu}}{dt}=0\phantom{\rule{4pt}{0ex}}.$$

Notice that when the metric is constant, we have the familiar equation:
that is, the geodesics are straight lines.

$$\frac{{d}^{2}{\gamma}^{\lambda}}{d{t}^{2}}=0;$$

- LeCun, Y.; Bengio, Y.; Hinton, G. Deep learning. Nature
**2015**, 521, 436. [Google Scholar] [CrossRef] [PubMed] - LeCun, Y.; Bottou, L.; Bengio, Y.; Haffner, P. Gradient-based learning applied to document recognition. Proc. IEEE
**1998**, 86, 2278–2324. [Google Scholar] [CrossRef] - Chaudhari, P.; Soatto, S. Stochastic gradient descent performs variational inference, converges to limit cycles for deep networks. arXiv
**2017**, arXiv:1710.11029. [Google Scholar] - Chaudhari, P.; Soatto, S. On the energy landscape of deep networks. arXiv
**2015**, arXiv:1511.06485. [Google Scholar] - Chaudhari, P.; Choromanska, A.; Soatto, S.; LeCun, Y.; Baldassi, C.; Borgs, C.; Chayes, J.; Sagun, L.; Zecchina, R. Entropy-SGD: Biasing gradient descent into wide valleys. arXiv
**2016**, arXiv:1611.01838. [Google Scholar] [CrossRef] - Amari, S. Natural Gradient Works Efficiently in Learning. Neural Comput.
**1998**, 10, 251–276. [Google Scholar] [CrossRef] - Adler, R.; Bazin, M.; Schiffer, M. Introduction to General Relativity; McGraw-Hill: New York, NY, USA, 1965. [Google Scholar]
- Huang, G.; Liu, Z.; Van Der Maaten, L.; Weinberger, K.Q. Densely Connected Convolutional Networks. arXiv
**2017**, arXiv:1706.01350. [Google Scholar] - Achille, A.; Soatto, S. On the emergence of invariance and disentangling in deep representations. arXiv
**2017**, arXiv:1706.01350. [Google Scholar] - Petersen, P. Riemannian Geometry; (GTM); Springer: Cham, Switzerland, 1998. [Google Scholar]

Architecture | $\mathit{d}=|\mathbf{Weights}|$ | $\mathit{N}=|\mathbf{Data}|$, CIFAR | $\mathit{N}=|\mathbf{Data}|$, SVHN |
---|---|---|---|

ResNet | 1.7 M | 60 K | 600 K |

Wide ResNet | 11 M | 60 K | 600 K |

DenseNet (k = 12) | 1 M | 60 K | 600 K |

DenseNet (k = 24) | 27.2 M | 60 K | 600 K |

© 2020 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).