# Shallow neural networks as Wasserstein gradient flows

## Contents

## Motivation

Artificial neural networks (ANNs) consist of layers of artificial "neurons" which take in information from the previous layer and output information to neurons in the next layer. Gradient descent is a common method for updating the weights of each neuron based on training data. While in practice every layer of a neural network has only finitely many neurons, it is beneficial to consider a neural network layer with infinitely many neurons, for the sake of developing a theory that explains how ANNs work. In particular, from this viewpoint the process of updating the neuron weights for a shallow neural network can be described by a Wasserstein gradient flow.

## Single Layer Neural Networks

{See also Mathematics of Artificial Neural Networks}

### Discrete Formulation

Let us introduce the mathematical framework and notation for a neural network with a single hidden layer.^{[1]} Let be open . The set represents the space of inputs into the network. There is some unknown function which we would like to approximate. Let be the number of neurons in the hidden layer. Define

be given by

where is a fixed activation function and is a space of possible parameters . The goal is to use training data to repeatedly update the weights and based on how close is to the function . More concretely, we want to find that minimizes the loss function:

A standard way to choose and update the weights is to start with a random choice of weights and perform gradient descent on these parameters. Unfortunately, this problem is non-convex, so the minimizer may not be achieved. It turns out in practice, neural networks are surprisingly good at finding the minimizer. A nicer minimization problem that may provide insight into how neural networks work is a neural network model with infinitely many neurons.

### Continuous Formulation

For the continuous formulation (i.e. when ), we rephrase the above mathematical framework. In this case, it no longer makes sense to look for weights that minimize the loss function. We instead look for a probability measure such that

minimizes the loss function:

- .

Here is an activation function with parameter . We will in fact restrict choices of to probability measures with finite second moment, denoted . This is a small technicality to ensure that the Wasserstein metric is indeed a metric.

Note that by restricting choices of to probability measures of the form , the above minimization problem generalizes to case with finitely many neurons as well.

To avoid overfitting the network to the training data, a potential term is added the loss function. For the remainder of this article, we define the loss function to be:

for a convex potential function . Often we choose . In fact, is convex (along linear interpolations), in contrast to the minimization function in the finite neuron case.

## Gradient Flow

When , the gradient flow of a differentiable function starting at a point is a curve satisfying the differential equation

- .

where is the gradient of g.^{[2]}

Crucially, the gradient flow heads in the direction that decreases the value of the fastest. We would like to use this nice property of gradient flow in our setting with the functional . However, it is not immediately straightforward how to do this, since is defined on the space of probability measures, rather than on , so the usual gradient is not defined. Before we generalize the notion of gradient flow, recall that is the unique function from to such that

- ,

where is the directional derivative of in the direction . Motivated by this and using the Riemannian structure of the space of probability measures, we can define the a notion of gradient for our loss functional .

Note that one can define gradient flows in a general Hilbert space.

### Wasserstein Gradient / Subdifferential

We are looking for an element in the tangent space of at such that

for any absolutely continuous curve in with .

We claim that in fact

where is the first variation of at ^{[3]} (also called the functional derivative).

We provide a formal argument for this equality that makes the most sense when is absolutely continuous with respect to the Lebesgue measure. In this case, we can think of as a density function with . We can further assume that is in . Therefore the same notion of gradient for exists for , and in fact

Thus by definition of gradient and inner product, we should have

by the continuity equation for and divergence theorem,

where is the unique velocity vector corresponding to by the equivalence of absolutely continuous curves and solutions of the continuity equation. Now by the definition of the inner product structure of , we have

Therefore we have

so the gradient flow for is an absolutely continuous curve of probability measure such that

- .

Now we actually compute this gradient flow for our loss functional .

### Computing the Wasserstein Gradient Flow for F

First, we compute the first variation ( or functional derivative) of a function from to of

Therefore we have

Hence the Wasserstein gradient flow is

- .

## Open Problems

### Generalization

Generalization error is how well a model generalizes for a new data not in your training data set. In practice, gradient descent does generalize really well, but it is an open problem to provide a theoretical framework to guarantee generalization. Wang, Meng, Chen and Liu 2021 made progress on studying the implicit regularization of the algorithm, and provide a framework for convergence. ^{[4]}

## References

- ↑ X. Fernandez-Real and A. Figalli,
*The Continuous Formulation of Shallow Neural Networks as Wasserstein-Type Gradient Flows* - ↑ G. Schiebinger,
*Gradient Flow in Wasserstein Space* - ↑ L. Ambrosio, N. Gigli, G. Savaré,
*Gradient Flows in Metric Spaces and in the Space of Probability Measures* - ↑ B. Wang, Q. Meng, W. Chen, T. Liu,
*The Implicit Regularization for Adaptive Optimization Algorithms on Homogeneous Neural Networks*