Shallow neural networks as Wasserstein gradient flows: Difference between revisions

From Optimal Transport Wiki
Jump to navigation Jump to search
 
(16 intermediate revisions by the same user not shown)
Line 69: Line 69:
:<math> \langle  \nabla_{W_2} F (\mu_*), \frac{d}{dt}\mu(t)|_{t=0} \rangle_{W_2} = \lim_{h \rightarrow 0} \frac{F(\mu(h)) - F(\mu_*)}{h}</math>
:<math> \langle  \nabla_{W_2} F (\mu_*), \frac{d}{dt}\mu(t)|_{t=0} \rangle_{W_2} = \lim_{h \rightarrow 0} \frac{F(\mu(h)) - F(\mu_*)}{h}</math>


for any absolutely continuous curve <math> \mu(h) </math> in <math>\mathcal{P}_2(\Omega) </math> with <math> \mu(0)=\mu_* </math>.
for any absolutely continuous curve <math> \mu(t) </math> in <math>\mathcal{P}_2(\Omega) </math> with <math> \mu(0)=\mu_* </math>.


We claim that in fact
We claim that in fact
Line 75: Line 75:
:<math> \nabla_{W_2} F (\mu_*) = - \nabla \cdot (\mu_* \nabla \frac{\delta F}{\delta \mu_*}) </math>
:<math> \nabla_{W_2} F (\mu_*) = - \nabla \cdot (\mu_* \nabla \frac{\delta F}{\delta \mu_*}) </math>


where <math> \frac{\delta F}{\delta \mu_*} </math> is the first variation of <math> F </math> at <math> \mu_* </math> (also called the [https://en.wikipedia.org/wiki/Functional_derivative#cite_note-ParrYangP246A.2-3 functional derivative]).  
where <math> \frac{\delta F}{\delta \mu_*} </math> is the first variation of <math> F </math> at <math> \mu_* </math> <ref name="Ambrosio" /> (also called the [https://en.wikipedia.org/wiki/Functional_derivative#cite_note-ParrYangP246A.2-3 functional derivative]).  


We provide a formal argument for this equality that makes the most sense when <math> \mu </math> is absolutely continuous with respect to the Lebesgue measure. In this case, we can think of <math> \mu </math> as a density function with <math> d \mu(x) = \mu(x) dx </math>. We can further assume that <math> \mu </math> is in <math> L^2(\Omega) </math>. Therefore the same notion of gradient for <math> L^2 </math> exists for <math> F </math>, and in fact  
We provide a formal argument for this equality that makes the most sense when <math> \mu </math> is absolutely continuous with respect to the Lebesgue measure. In this case, we can think of <math> \mu </math> as a density function with <math> d \mu(x) = \mu(x) dx </math>. We can further assume that <math> \mu </math> is in <math> L^2(\Omega) </math>. Therefore the same notion of gradient for <math> L^2 </math> exists for <math> F </math>, and in fact  
Line 81: Line 81:
:<math> \nabla_{L^2}F(\mu) = \frac{\delta F}{\delta \mu} </math>
:<math> \nabla_{L^2}F(\mu) = \frac{\delta F}{\delta \mu} </math>


Thus by definition of <math> L^2 </math> gradient, we should have
Thus by definition of <math> L^2 </math> gradient and <math> L^2 </math> inner product, we should have


===Wasserstein Distance===
:<math>\lim_{h \rightarrow 0} \frac{F(\mu(h)) - F(\mu_*)}{h}= \langle \frac{\delta F}{\delta \mu_*} , \frac{d}{dt}\mu(t)|_{t=0} \rangle_{L^2}</math>
Let us first define the (pth) Wasserstein distance between two probability measures. <ref name="Ambrosio"/> This can be defined for probability measures in any separable metric space. Let <math> \mu, \nu\in \mathcal{P}(\Omega) </math> and let <math> \Gamma(\mu, \nu) </math> denote the space of transport plans from <math> \mu </math> to <math> \nu </math>. Define the pth Wasserstein distance from <math> \mu </math> to <math> \nu </math> to be:


:<math> W_p(\mu,\nu) := \min \{ \int_{\Omega \times \Omega} d(\xi_1,\xi_2)^p d\gamma(\xi_1,\xi_2): \gamma \in \Gamma(\mu,\nu)\} </math>
:<math> = \int \frac{\delta F}{\delta \mu_*} \frac{d}{dt}\mu(t)|_{t=0} dx </math>  


where <math> d(\xi_1,\xi_2) </math> is the distance between  <math> \xi_1 </math> and <math> \xi_2 </math> in the metric space <math> \Omega \times \Omega </math>. In this context, <math> \Omega \times \Omega </math> is just a subset of <math> \mathbb{R}^{d} </math> for some <math> d </math> with the euclidean metric. Often <math> p = 2 </math>.
by the continuity equation for <math>\mu(t) </math> and divergence theorem,


===First Variation / Functional Derivative===
:<math> \int \frac{\delta F}{\delta \mu_*} \frac{d}{dt}\mu(t)|_{t=0} dx = - \int \frac{\delta F}{\delta \mu_*} (\nabla \cdot (v_*\mu_*)) dx= \int \nabla \frac{\delta F}{\delta \mu_*} (v_*\mu_*)dx = \int \nabla \frac{\delta F}{\delta \mu_*} v_* d\mu_*</math>


The first variation ( or [https://en.wikipedia.org/wiki/Functional_derivative functional derivative]) of a function from <math>\mathcal{P}(\Omega) </math> to <math> \mathbb{R} </math> measures
where <math> v_* </math> is the unique velocity vector corresponding to <math> \mu_* </math> by the equivalence of absolutely continuous curves and solutions of [http://34.106.105.83/wiki/The_continuity_equation_and_Benamour_Brenier_formula the continuity equation]. Now by the definition of the inner product structure of <math> (\mathcal{P}_2(\mathbb{R}^d), W_2)</math>, we have


: <math> \frac{\delta F}{\delta \mu}(\mu_*) = \int_D \Phi( \cdot, x) [\int_\Omega \Phi(\bar{\xi},x)d \mu_*(\bar{xi}) - f(x) ]dx + V </math>
:<math>\int \nabla \frac{\delta F}{\delta \mu_*} v_* d\mu_* = \langle - \nabla \cdot (\mu \nabla \frac{\delta F}{\delta \mu_*}), \frac{d}{dt}\mu(t)|_{t=0} \rangle_{W_2}.</math>


===Wasserstein Subdifferential===
Therefore we have


: <math> \nabla \frac{\delta F}{\delta \mu}(\mu_*) = \int_D \nabla_{\xi} \Phi( \cdot, x) [\int_\Omega \Phi(\bar{\xi},x)d \mu_*(\bar{xi}) - f(x) ]dx + \nabla V </math>
:<math>\nabla_{W_2}F(\mu_*)= - \nabla \cdot (\mu \nabla \frac{\delta F}{\delta \mu_*}).</math>


===Wasserstein Gradient Flow===
so the gradient flow for <math> F </math> is an absolutely continuous curve of probability measure <math> \mu_t </math> such that


:<math> \partial_t \mu_t = \rm{div}( \mu_t \nabla \frac{\delta F}{\delta \mu} (\mu_t)) </math>
:<math> \partial_t \mu_t = \nabla \cdot (\mu_t \nabla \frac{\delta F}{\delta \mu_t}) </math>.


==Main Results==
Now we actually compute this gradient flow for our loss functional <math> F</math>.


===Consistency Between Infinite and Finite Cases===
===Computing the Wasserstein Gradient Flow for F ===


First, we compute the first variation ( or [https://en.wikipedia.org/wiki/Functional_derivative functional derivative]) of a function from <math>\mathcal{P}(\Omega) </math> to <math> \mathbb{R} </math> of <math> F </math>
:<math> \frac{\delta F}{\delta \mu}(\mu_*) = \int_D \Phi( \cdot, x) [\int_\Omega \Phi(\bar{\xi},x)d \mu_*(\bar{xi}) - f(x) ]dx + V </math>
Therefore we have
: <math> \nabla \frac{\delta F}{\delta \mu}(\mu_*) = \int_D \nabla_{\xi} \Phi( \cdot, x) [\int_\Omega \Phi(\bar{\xi},x)d \mu_*(\bar{xi}) - f(x) ]dx + \nabla V .</math>
Hence the  Wasserstein gradient flow is
:<math> \partial_t \mu_t = \rm{div}( \mu_t \nabla \frac{\delta F}{\delta \mu} (\mu_t)) </math>.
==Open Problems==
===Generalization===
[https://en.wikipedia.org/wiki/Generalization_error 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. <ref name="Wang" />


==References==
==References==
Line 117: Line 133:
<ref name="Schiebinger"> [https://personal.math.ubc.ca/~geoff/courses/W2019T1/Lecture16.pdf G. Schiebinger, ''Gradient Flow in Wasserstein Space''] </ref>
<ref name="Schiebinger"> [https://personal.math.ubc.ca/~geoff/courses/W2019T1/Lecture16.pdf G. Schiebinger, ''Gradient Flow in Wasserstein Space''] </ref>


<ref name="Glaudo"> [https://www.maa.org/press/maa-reviews/an-invitation-to-optimal-transport-wasserstein-distances-and-gradient-flows A. Figalli, F. Glaudo, ''An Invitation to Optimal Transport, Wasserstein Distances, and Gradient Flows''] </ref>
<ref name="Wang"> [https://arxiv.org/pdf/2012.06244.pdf B. Wang, Q. Meng, W. Chen, T. Liu, ''The Implicit Regularization for Adaptive Optimization Algorithms on Homogeneous Neural Networks''] </ref>
 


</references>
</references>

Latest revision as of 02:33, 20 March 2022


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