Mean Field Analysis of Neural Networks: A Law of Large Numbers
Justin Sirignano, Konstantinos Spiliopoulos
Introduction
Neural networks have achieved immense practical success over the past decade. Neural networks are nonlinear statistical models whose parameters are estimated from data using stochastic gradient descent. They have been employed as critical components of many important technologies in a variety of industries. This practical success has sparked significant interest in their mathematical analysis. Currently, there is limited mathematical understanding of neural networks. This paper analyzes the asymptotic behavior of neural networks, rigorously proving that the empirical distribution of their parameters converges to the solution of a nonlinear partial differential equation (PDE).
Neural network models have revolutionized fields such as image, text, and speech recognition. They are actively used in a variety of applications. In image recognition, neural networks are able to accurately identify and recognize objects in images using only the raw pixels. Neural networks are used for image recognition in applications such as self-driving cars, image searches on search engines such as Google, and facial recognition for security systems (see , , , and ). In speech recognition, neural networks are used to develop computer systems that automatically understand human speech (see , , , and ). Applications include voice control of certain systems in vehicles, transcription (automatically converting human speech to written text), interactive voice response for customer service, and spoken commands for smartphones. In text recognition, neural networks are used to automatically translate text from one language (e.g., English) to another language (e.g., Italian); see and . They have also been used for automatically generating summaries of long documents; see and .
In addition, there is growing interest in applying neural networks to engineering, robotics, medicine, and finance. Neural networks are being used in reduced-form models of the Navier-Stokes equation in turbulent conditions (see and ). , , and describe applications in robotics. Neural networks have been used to identify cancer and to model protein folding . In finance, neural networks have been used to model loan default and prepayment risk and to model high frequency financial data . Neural networks have also been used to solve high-dimensional PDEs in financial applications .
Due to the impact that neural networks have had on practical applications, there is a significant interest in better understanding their mathematical properties. However, the existing literature is relatively limited, with only a few recent papers such as , , and . There also exist classical results regarding the approximation power of neural networks , , and .
Our result characterizes neural networks with a single hidden layer in the asymptotic regime of large network sizes and large numbers of stochastic gradient descent iterations. We rigorously prove that the empirical distribution of the neural network parameters will weakly converge to a distribution. This distribution satisfies a nonlinear partial differential equation. The proof relies upon weak convergence analysis for interacting particle systems. The result can be considered a “law of large numbers” for neural networks when both the network size and the number of stochastic gradient descent steps grow to infinity.
Recently, rigorously established a weak convergence result for a class of machine learning algorithms. Weak convergence analysis has been widely used in other fields (for example, see , , , , , , and for a non-exhaustive list). In fact, mean field analysis has been actively used for many years to study biological neural networks and physical systems of interacting particles; see for example , , , , and the references therein.
Upon completion of this work, we became aware of the very recent work of where a related PDE limit result for neural networks is derived; see also the recent work . Our convergence analysis, setup, and assumptions are different. In , it is assumed that the gradient of the neural network is a priori globally Lipschitz and bounded and under this assumption a similar PDE result as well as certain rates of convergence are established. In our work, we do not assume that the gradient of the neural network is a priori globally Lipschitz or bounded. Often, neural network models (and their gradients) are not globally Lipschitz and not bounded. In this paper, we assume that the data come from a distribution that has its first moments bounded and that the initialization is done according to distributions with certain moment bounds. Based on this assumption, we rigorously prove relative compactness of the pre-limit measure valued process, identification of its limit, and uniqueness of the limit point in the appropriate space. Our method of proof leverages on weak convergence analysis in an appropriate Skorokhod space for measure-valued processes (similar to the approaches in and ). In particular, the relative compactness and uniqueness proof addresses the challenge of neural networks not being a priori globally Lipschitz nor globally bounded using the structure of the stochastic gradient descent algorithm.
where the data is assumed to have a joint distribution . We shall write for the state spaces of and , respectively. The parameters are estimated using stochastic gradient descent:
where is the learning rate and . Stochastic gradient descent minimizes (1.2) using a sequence of noisy (but unbiased) gradient descent steps . Note that typically is not a priori globally Lipschitz nor globally bounded as a function of . Stochastic gradient descent typically converges more rapidly than gradient descent for large datasets. For this reason, stochastic gradient descent is widely used in machine learning.
The neural network’s output can be re-written in terms of the empirical measure:
denotes the inner product of and . For example, .
Our main results are stated below. Theorem 1.2 (and the associated Remark 1.3) is a law of large numbers describing the distribution of the trained parameters when is large. Theorem 1.6 describes the behavior of individual parameters when is large. Theorem 1.6 is a “propagation of chaos” result. Section 1.1 presents several insights provided by these asymptotic results.
where .
Since weak convergence to a constant implies convergence in probability, Theorem 1.2 leads to the stronger result of convergence in probability
for every and where is the metric for .
Assume Assumption 1.1. Suppose that admits a density and there exists a unique solution to the nonlinear partial differential equation
such that vanishes as . Then, we have that the solution to the measure evolution equation (1.7) is such that
Notice that by setting , the partial differential equation for in Corollary 1.4 can be written as
where is the divergence operator with respect to the variable and is defined as
In addition, Theorem 1.2 and Corollary 1.4 imply that the objective function from (1.2) satisfies
In Theorem 1.6 we prove that the neural network has the “propagation of chaos” property.
The law of large numbers (1.7) suggests several interesting characteristics of trained neural networks (at least in the setting studied in this paper).
As , the neural network converges (in probability) to a deterministic model. This is despite the fact that the neural network is randomly initialized and it is trained on a random sequence of data samples via stochastic gradient descent.
The learning rate was assumed to be constant and to not decay with time. However, notice that the hidden layer has been normalized by and it is this normalization by in the hidden layer that replaces the role of the learning rate decay, enabling convergence.
The propagation of chaos result (1.10) indicates that, as , the dynamics of the weights will become independent of the dynamics of the weights for any . Note that the dynamics are still random due to the random initialization. However, the dynamics of the -th set of weights will be uncorrelated with the dynamics of the -th set of weights in the limit as .
In order to illustrate some aspects of the theoretical results of this paper, we performed the following numerical study.
Figure 1 displays the convergence of the distribution of the parameters in a trained neural network as the number of hidden units . The neural network has a single hidden layer followed by a softmax function. Figure 1 reports the distribution of the parameters connecting the hidden layer to the softmax function. The distributions are presented as histograms. The neural network is trained on the MNIST dataset, which is a standard image dataset in machine learning . The dataset includes images of handwritten numbers . The neural network is trained to identify the handwritten numbers using only the image pixels as an input (i.e., it learns to recognize images as a human would). In the MNIST dataset, each image has pixels. A pixel takes values in .The pixel values are normalized to $$ for the purposes of training the neural network. Neural networks can achieve 98-99% out-of-sample accuracy on the MNIST dataset.
Figure 1 shows that the distribution of parameters converges to a fixed distribution as . This can be seen by the fact that the distributions for , , and are nearly identical. A priori it is unclear if the distribution of neural network parameters should converge as . Our theory and numerical results confirm that this is indeed the case. Indeed, as gets large, we see that the empirical distribution of the parameters connecting the hidden layer to the softmax function converges to a specific deterministic distribution.
2 Overview of the Proof
Relative Compactness
For each , there is a compact subset of E such that
Given now that , the proof of the lemma is concluded. ∎
We start by noticing that a Taylor expansion gives for
for points in the segments connecting with and with , respectively.
Let’s now establish a bound on for . Let .
where Assumption 1.1 was used. Let’s now establish a bound on for . Making use of the uniform bounds established in Lemma 2.1, we obtain similarly to the previous bound
Now, we return to equation (2.1). By Lemma 2.1, the quantities are bounded in expectation for . Therefore, for ,
where is some unimportant constant. Then, the statement of the Lemma follows. ∎
Given Lemmas 2.2 and 2.3, Theorem 8.6 of Chapter 3 of , gives the statement of the lemma. (See also Remark 8.7 B of Chapter 3 of regarding replacing with in the regularity condition B of Theorem 8.6.) ∎
We conclude this section with the proof of the a-priori bound of Lemma 2.1.
We start by establishing some useful a-priori bounds on and . The unimportant finite constant may change from line to line. We first observe that
where to derive the last line we used the definition of via (1.1) and the uniform boundedness assumption on . Then, we subsequently obtain that
Let us now define and . Then we have
which by the discrete Gronwall lemma gives the bound
for a possibly different constant that may depend on , where the relation was used in the last step. Going back now to the bound for we obtain
Raising this to power , we have for a constant that may depend on
Let us bound now each of the terms on the right hand side of the last display. We have for some constant that may change from line to line
for a constant that may change from line to line. Taking now expectation, using Assumption 1.1, the a-priori bound (2.2) and the fact that we obtain
Identification of the Limit
for points in the segments connecting with and with , respectively. Notice now that the uniform bounds of Lemma 2.1 and the relation (1.3) imply that as gets large
The term Recall that when we write we mean that is stochastically bounded. is a result of , the bounds from Lemma 2.1 as well as the moment bounds on from Assumption 1.1. We next define the drift and martingale components:
Combining the different terms together, we then obtain
Next, we define the scaled versions of and :
The scaled empirical measure satisfies, as grows,
In fact as we show below and converge to in as .
Let be the algebra generated by and . If , then
Let be the probability measure of a convergent subsequence of . Each takes values in the set of probability measures \mathcal{M}\big{(}D_{E}([0,T])\big{)}. Relative compactness, proven in Section 2, implies that there is a subsequence which weakly converges. We must prove that any limit point of a convergent subsequence will satisfy the evolution equation (1.7).
Let be a convergent subsequence with a limit point . Then is a Dirac measure concentrated on and satisfies the measure evolution equation (1.7).
Then, by the proof of Lemma 3.1, we obtain for large
Since is continuous and is uniformly bounded (due to the uniform boundedness results of Section 2),
It remains to prove that the evolution equation (1.7) has a unique solution. This is the content of Section 4.
Uniqueness
We prove uniqueness of a solution to the evolution equation (1.7). We will set up a Picard type of iteration and prove that it has a unique fixed point through a contraction mapping. We start by noticing that we can write
We remark here that a solution to (4.1), , is associated to the nonlinear random process (see for example ) satisfying the random ordinary differential equation (ODE)
This ODE is random due to the random initial data.
It is clear that if is a fixed point of , then is a solution to (4.1). Conversely, if is a solution to (4.2) then its law will be a fixed point of , implying that . In addition, if is a weak measure valued solution to (4.1), then it must be a fixed point of and thus satisfy (4.2), proving our result.
Lemma 4.1 shows that there is regularity in time and it also provides us with some useful a-priori uniform bounds.
Let and be given. Then, there are constants , depending on , such that
and for every we have that
Let’s examine first and establish a bound on its growth. The constant may change from line to line and it may also depend upon the final time and on .
Therefore, by Gronwall’s inequality, there exists a constant such that
for . Therefore, returning to (4.4) and recalling Assumption 1.1 we get that uniformly in , there exist constants such that
and the claimed bound follows by taking supremum over all , expectation and using the previously derived uniform bound for . Let us now prove the second statement of the lemma. Similarly to the calculations above and using the uniform moment bounds on and together with Assumption 1.1, we have
For and define the metric
where is the set of probability measures on such that the marginal distributions are and , respectively.
Now we show existence and uniqueness of a fixed point for the mapping , as defined via (4.5). If a solution to (4.2) exists, then it must be a fixed point of (defined via equation (4.5)). This is an immediate consequence of Lemma 4.1. Therefore, if has a unique solution, there can be at most one solution to (4.2). If (4.2) has at most one solution, (4.1) has at most one solution. Therefore, if has a unique fixed point, this proves uniqueness for (4.1).
Due to Lemma 4.1 we need only to consider the space of measures that have bounded moments up to order . By known results, see for example , the space of measures with finite moments endowed with the metric is complete and separable. Due to closedness, the space of measures with bounded moments of order four is a complete and separable metric space when endowed with the Wasserstein metric . Therefore, in the arguments below we work with the space of measures that have bounded the first four moments and we consider the metric . We will show that there is a unique fixed point by proving a contraction.
Lemma 4.2 shows that for a large enough bound, maps from a subspace of bounded moments to the same subspace of bounded moments.
Assume that the measure is such that (where will be chosen below). Using the same steps as in Lemma 4.1, we can show that for some (to be chosen later),
We can now prove a contraction and then apply the Banach fixed-point theorem to prove that there is a unique fixed point.
For two elements , let us set for with . So, let satisfying (4.5) with and satisfying (4.5) with . The processes and have the same initial conditions. That is,
We now prove a contraction for the mapping for some . By definition, and have marginal distributions and , respectively, on the time interval . Once this is proven, we can extend this to the entire interval since is not affected by the input measures or by which subinterval of we are considering. We have the following lemma.
Let and . Then, there exist constants that may depend on such that
for any . In addition, if has compact support, there exists a constant that may depend on such that
First, let’s address the mean-field term. Recall that is bounded and that has bounded marginal moments via Assumption 1.1. Therefore, for ,
We next bound the term \bigg{|}\int_{0}^{t}\int_{\mathcal{X}\times\mathcal{Y}}\left\langle c^{\prime}_{s}\sigma(w^{\prime}_{s}x),m^{2}-m^{1}\right\rangle\sigma(w_{s}^{1}\cdot x)\pi(dx,dy)ds\bigg{|}. We have that
Let the random variables have marginal distribution and have marginal distribution . Then, for ,
where again Assumption 1.1 was used for the moment bounds of . The inequality holds for any joint distribution of and . Then, the auxiliary calculations provided in Appendix A show that (4.6) can be bounded in terms of :
Thus, we overall get that there is a constant such that
Similar calculations also give the necessary bound for . For completeness, the details are provided in Appendix B.
Hence, for , we have the bound
Setting for notational convenience , the latter relation gives
where we used the fact that is monotonically increasing.
Now, note that can be bounded in terms of , the initial condition. In particular, using the boundedness of , the bound on , the moments bounds for the distribution , and the fact that , we get for some constant that changes from line to line
This bound holds for any . Then,
Raising this to the power four gives for some constants different than before
Next, we take expectation and apply the Cauchy-Schwartz inequality on the right hand side. We obtain
The latter concludes the proof due to Assumption 1.1.
By Assumption 1.1 we have that there exists a such that the moment generating function exists, i.e.
Lemma 4.3 immediately proves there is a contraction on the interval . Indeed,
Then, choose such that , ,and , where is from Lemma 4.2. That is, we choose
If , then for and we have proven uniqueness on the sub-interval (via the Banach fixed-point theorem).
In fact, this directly proves our next Lemma 4.4 regarding uniqueness of the limit point over the entire interval .
Let . The mapping has a unique fixed point.
By Lemmas 4.2, 4.3 and the Banach fixed-point theorem we readily obtain that there is such that will be a contraction map leading to (4.5) having a unique solution on . We then extend this construction to the whole interval by dividing the interval into sub-intervals . In each sub-interval, it can be shown that the solution is unique by proving a contraction as was done in Lemma 4.3, which can be done as can be always taken to be of the same magnitude, i.e. it does not depend on which sub-interval is being examined. This concludes the proof. ∎
Proof of the Main Results
We now collect the results to prove Theorem 1.2, Corollary 1.4, and Theorem 1.6.
Let be the probability measure corresponding to . Each takes values in the set of probability measures \mathcal{M}\big{(}D_{E}([0,T])\big{)}. Relative compactness, proven in Section 2, implies that every subsequence has a further sub-sequence which weakly converges. Section 3 proves that any limit point of will satisfy the evolution equation (1.7). Section 4 proves that the solution of the evolution equation (1.7) is unique. Therefore, by Prokhorov’s Theorem, weakly converges to , where is the distribution of , the unique solution of (1.7). That is, converges in distribution to . ∎
The result follows from applying integration by parts to (1.7) using the assumption that as . We also note that if a solution exists to (1.4), then it is unique due to the uniqueness of (1.7). ∎
Conclusion
In this paper we develop a law of large numbers result for neural networks with a single hidden layer as the number of hidden units and stochastic gradient descent iterations grow. The limiting distribution of the parameters is rigorously shown to satisfy an explicitly stated first-order nonlinear deterministic PDE, in the form of a measure evolution equation. The limiting PDE is a function of the inputs to the model, such as the learning rate, activation function, and distribution of the observed data. A numerical study on the well-known MNIST dataset illustrates the theoretical results of this paper. In related work which builds upon the results in this paper, a central limit theorem has been proven for single-layer neural networks in and a law of large numbers has been proven for deep neural networks in .
Appendix A Proof of (4.7)
We will show that (4.6) can be bounded in terms of . For notational convenience, define .
The sixth line uses the Cauchy-Schwartz inequality and Young’s inequality. The seventh line uses the facts that and have bounded fourth order moments. The eighth line uses Young’s inequality. We have also used the facts that and when and .
Since this inequality holds for any joint distribution , we have that (4.7) holds.
Appendix B Proof of (4.8)
Due to having bounded moments, (see Section 4 for similar calculations). Due to Assumption 1.1 on ,
Using these inequalities and the bounded moments of , we can calculate the upper bound
Using the same approach as in the bound for (4.6), see Appendix A, we have the bound