Size-Independent Sample Complexity of Neural Networks
Noah Golowich, Alexander Rakhlin, Ohad Shamir
Introduction
One of the major challenges involving neural networks is explaining their ability to generalize well, even if they are very large and have the potential to overfit the training data (Neyshabur et al., 2014; Zhang et al., 2016). Learning theory teaches us that this must be due to some inductive bias, which constrains one to learn networks of specific configurations (either explicitly, e.g., via regularization, or implicitly, via the algorithm used to train them). However, understanding the nature of this inductive bias is still largely an open problem.
A useful starting point is to consider the much more restricted class of linear predictors (). For this class, we have a very good understanding of how its generalization behavior is dictated by the norm of . In particular, assuming that (where signifies Euclidean norm), and the distribution is such that almost surely, it is well-known that the generalization error (w.r.t. Lipschitz losses) given training examples scales as , completely independent of the dimension of . Thus, it is very natural to ask whether in the more general case of neural networks, one can obtain similar “size-independent” results (independent of the networks’ depth and width), under appropriate norm constraints on the parameters. This is also a natural question, considering that the size of modern neural networks is often much larger than the number of training examples.
Classical results on the sample complexity of neural networks do not satisfy this desideratum, and have a strong explicit dependence on the network size. For example, bounds relying on the VC dimension (see Anthony and Bartlett (2009)) strongly depend on both the depth and the width of the network, and can be trivial once the number of parameters exceeds the number of training examples. Scale-sensitive bounds, which rely on the magnitude of the network parameters, can alleviate the dependence on the width (see Bartlett (1998); Anthony and Bartlett (2009)). However, most such bounds in the literature have a strong (often exponential) dependence on the network depth. To give one recent example, Neyshabur et al. (2015) use Rademacher complexity tools to show that if the parameter matrices in each of the layers have Frobenius norms upper-bounded by respectively, and under suitable assumptions on the activation functions, the generalization error scales (with high probability) as
Although this bound has no explicit dependence on the network width (that is, the dimensions of ), it has a very strong, exponential dependence on the network depth , even if for all . Neyshabur et al. (2015) also showed that this dependence can sometimes be avoided for anti-symmetric activations, but unfortunately this is a non-trivial assumption, which is not satisfied for common activations such as the ReLU. Bartlett et al. (2017) use a covering numbers argument to show a bound scaling as
where denotes the spectral norm of , denotes the -norm of the 2-norms of the rows of , and where we ignore factors logarithmic in and the network width. Unlike Eq. (1), here there is no explicit exponential dependence on the depth. However, there is still a strong and unavoidable polynomial dependence: To see this, note that for any , , so the bound above can never be smaller than
In particular, even if we assume that is a constant, the bound becomes trivial once . Finally, and using the same notation, Neyshabur et al. (2017) utilize a PAC-Bayesian analysis to prove a bound scaling as
Can this depth dependency be avoided, assuming the norms are sufficiently constrained? We argue that in some cases, it must be true. To see this, let us return to the well-understood case of linear predictors, and consider generalized linear predictors of the form
where is the ReLU function. Like plain-vanilla linear predictors, the generalization error of this class is well-known to be , assuming the inputs satisfy almost surely. However, it is not difficult to show that this class can be equivalently written as a class of “ultra-thin” ReLU networks of the form
(where is a vector and are scalars), where the depth is arbitrary. Therefore, the sample complexity of this class must also scale as : This depends on the norm product , but is completely independent of the network depth as well as the dimension of . We argue that a “satisfactory” sample complexity analysis should have similar independence properties when applied on this class.
In more general neural networks, the vector and scalars become matrices , and the simple observation above no longer applies. However, using the same intuition, it is natural to try and derive generalization bounds by controlling , where is a suitable matrix norm. Perhaps the simplest choice is the spectral norm (and indeed, a product of spectral norms was utilized in some of the previous results mentioned earlier). However, as we formally show in Sec. 5, the spectral norm alone is too weak to get size-independent bounds, even if the network depth is small. Instead, we show that controlling other suitable norms can indeed lead to better depth dependence, or even fully size-independent bounds, improving on earlier works. Specifically, we make the following contributions:
In Sec. 3, we show that the exponential depth dependence in Rademacher complexity-based analysis (e.g. Neyshabur et al. (2015)) can be avoided by applying contraction to a slightly different object than what has become standard since the work of Bartlett and Mendelson (2002). For example, for networks with parameter matrices of Frobenius norm at most , the bound in Eq. (1) can be improved to
where is the input dimension. Again, the dependence on is polynomial and quite mild. In contrast, Neyshabur et al. (2015) studied a similar setup and only managed to obtain an exponential dependence on .
In Sec. 4, we develop a generic technique to convert depth-dependent bounds to depth-independent bounds, assuming some control over any Schatten norm of the parameter matrices (which includes, for instance, the Frobenius norm and the trace norm as special cases). The key observation we utilize is that the prediction function computed by such networks can be approximated by the composition of a shallow network and univariate Lipschitz functions. For example, again assuming that the Frobenius norms of the layers are bounded by , we can further improve Eq. (5) to
In contrast, we show the following bound for any (ignoring some lower-order logarithmic factors):
where is an upper bound on the Schatten -norm of , and is a lower bound on . Again, by upper bounding the by its first argument, we get a bound independent of the depth , assuming the norms are suitably constrained.
In Sec. 5, we provide a lower bound, showing that for any , the class of depth-, width- neural networks, where each parameter matrix has Schatten -norm at most , can have Rademacher complexity of at least
This somewhat improves on Bartlett et al. (2017, Theorem 3.6), which only showed such a result for (i.e. with spectral norm control), and without the term. For , it matches the upper bound in Eq. (6) in terms of the norm dependencies and . Moreover, it establishes that controlling the spectral norm alone (and indeed, any Schatten -norm control with ) cannot lead to bounds independent of the size of the network. Finally, the bound shows (similar to Bartlett et al. (2017)) that a dependence on products of norms across layers is generally inevitable.
Besides the above, we provide some additional remarks and observations in Sec. 6. Most of our technical proofs are presented in Sec. 7.
Finally, we emphasize that the bounds of Sec. 4 are independent of the network size, only under the assumption that products of norms (or at least ratios of norms) across all layers are bounded by a constant, which is quite restrictive in practice. For example, it is enough that the Frobenius norm of each layer matrix is at least , to get that Eq. (6) scales as where is the number of layers. However, our focus here is to show that at least some norm-based assumptions lead to size-independent bounds, and hope these can be weakened in future work.
Preliminaries
Neural Networks. Given the domain in Euclidean space, we consider (scalar or vector-valued) standard neural networks, of the form
Rademacher Complexity. The results in this paper focus on Rademacher complexity, which is a standard tool to control the uniform convergence (and hence the sample complexity) of given classes of predictors (see Bartlett and Mendelson (2002); Shalev-Shwartz and Ben-David (2014) for more details). Formally, given a real-valued function class and some set of data points , we define the (empirical) Rademacher complexity as
where is a vector uniformly distributed in . Our main results provide bounds on the Rademacher complexity (sometimes independent of , as long as they are assumed to have norm at most ), with respect to classes of neural networks with various norm constraints. Using standard arguments, such bounds can be converted to bounds on the generalization error, assuming access to a sample of i.i.d. training examples.
From Exponential to Polynomial Depth Dependence
To get bounds on the Rademacher complexity of deep neural networks, a reasonable approach (employed in Neyshabur et al. (2015)) is to use a “peeling” argument, where the complexity bound for depth networks is reduced to a complexity bound for depth networks, and then applying the reduction times. For example, consider the class of depth- ReLU real-valued neural networks, with each layer’s parameter matrix with Frobenius norm at most . Using some straightforward manipulations, it is possible to show that , which by definition equals
Iterating this inequality times, one ends up with a bound scaling as (as in Neyshabur et al. (2015), see also Eq. (1)). The exponential factor follows from the factor in Eq. (8), which in turn follows from applying the Rademacher contraction principle to get rid of the function. Unfortunately, this factor is generally unavoidable (see the discussion in Ledoux and Talagrand (1991) following Theorem 4.12).
where is an arbitrary parameter. We then perform a “peeling” argument similar to before, resulting in a multiplicative factor after every peeling step. Crucially, these factors accumulate inside the log factor, so that the end result contains only a factor, which by appropriate tuning of , can be further reduced to .
The formalization of this argument depends on the matrix norm we are using, and we will begin with the case of the Frobenius norm. A key technical condition for the argument to work is that we can perform the “peeling” inside the function. This is captured by the following lemma:
Letting be the rows of the matrix , we have
The supremum of this over all such that must be attained when for some , and for all . Therefore,
Since , this can be upper bounded by
where the equality follows from the symmetry in the distribution of the random variables. The right hand side in turn can be upper bounded by
(see equation 4.20 in Ledoux and Talagrand (1991)). ∎
With this lemma in hand, we can provide a bound on the Rademacher complexity of Frobnius-norm-bounded neural networks, which is as clean as Eq. (1), but where the factor is replaced by :
Let be the class of real-valued networks of depth over the domain , where each parameter matrix has Frobenius norm at most , and with activation functions satisfying Lemma 1. Then
Fix , to be chosen later. The Rademacher complexity can be upper bounded as
where ranges over all possible functions . Here we applied Lemma 1 with . Repeating the process, we arrive at
where . Define a random variable
(random as a function of the random variables ). Then
This means that satisfies a bounded-difference condition, which by the proof of Theorem 6.2 in (Boucheron et al., 2013), implies that is sub-Gaussian, with variance factor
Choosing and using the above, we get that Eq. (9) can be upper bounded as follows:
We note that for simplicity, the bound in Thm. 1 is stated for real-valued networks, but the argument easily carries over to vector-valued networks, composed with some real-valued Lipschitz loss function. In that case, one uses a variant of Lemma 1 to peel off the losses, and then proceed in the same manner as in the proof of Thm. 1. We omit the precise details for brevity.
A result similar to the above can also be derived for other matrix norms. For example, given a matrix , let denote the maximal -norm of its rows, and consider the class of depth- networks, where each parameter matrix satisfies for all (this corresponds to a setting, also studied in Neyshabur et al. (2015), where the -norm of the weights of each neuron in the network is bounded). In this case, we can derive a variant of Lemma 1, which in fact does not require positive-homogeneity of the activation function:
where denotes the vector infinity norm.
Using the same technique as before, we can use this lemma to get a bound on the Rademacher complexity for :
Let be the class of real-valued networks of depth over the domain , where for all , and with activation functions satisfying the condition of Lemma 2. Then
where is the -th coordinate of the vector .
The proofs of the theorem, as well as Lemma 2, appear in Sec. 7.
From Depth Dependence to Depth Independence
In this section, we develop a general result, which allows one to convert any depth-dependent bound on the Rademacher complexity of neural networks, to a depth-independent one, assuming that the Schatten -norms of the parameter matrices (for any ) is sufficiently controlled. We develop and formalize the main result in Subsection 4.1, and provide applications in Subsection 4.2. The proofs the results in this section appear in Sec. 7.
To motivate our approach, let us consider a special case of depth- networks, where
Each parameter matrix is constrained to be diagonal and of size .
The Frobenius norm of every is at most .
All activation functions are the identity (so the network computes a linear function).
Letting be the diagonal of , such networks are equivalent to
where denotes element-wise product. Therefore, if we would like the network to compute a non-trivial function, we clearly need that be bounded away from zero (e.g., not exponentially small in ), while still satisfying the constraint for all . In fact, the only way to satisfy both requirements simultaneously is if are all close to some 1-sparse unit vector, which implies that the matrices must be close to being rank-1.
It turns out that this intuition holds much more generally, even if we do not restrict ourselves to identity activations and diagonal parameter matrices as above. Essentially, what we can show is that if some network computes a non-trivial function, and the product of its Schatten -norms (for any ) is bounded, then there must be at least one parameter matrix, which is not far from being rank-1. Therefore, if we replace that parameter matrix by an appropriate rank-1 matrix, the function computed by the network does not change much. This is captured by the following theorem:
We now make the following crucial observation: A real-valued network with a rank-1 parameter matrix computes the function
This can be seen as the composition of the depth- network
Moreover, the norm constraints imply that the latter function is Lipschitz. Therefore, the class of networks we are considering is a subset of the class of depth- networks composed with univariate Lipschitz functions. Fortunately, given any class with bounded complexity, one can effectively bound the Rademacher complexity of its composition with univariate Lipschitz functions, as formalized in the following theorem.
The can be replaced by , where is the empirical Gaussian complexity of – see the proof in Sec. 7 for details.
Combining these ideas, our plan of attack is the following: Given some class of depth- networks, and an arbitrary parameter , we use Thm. 3 to relate their Rademacher complexity to the complexity of similar networks, but where for some , the -th parameter matrix is of rank-1. We then use Thm. 4 to bound that complexity in turn using the Rademacher complexity of depth- networks. Crucially, the resulting bound has no explicit dependence on the original depth , only on the new parameter . Formally, we have the following theorem, which is the main result of this section:
Consider the following hypothesis class of networks on :
for some parameters . Also, for any , define
In particular, one can upper bound this result by any choice of in . By tuning appropriately, we can get bounds independent of the depth . In the next subsection, we provide some concrete applications for specific choices of .
The parameters and , which divide the norm terms in Thm. 5, are both closely related to the notion of a margin. Indeed, if we consider binary or multi-class classification, then bounds as above w.r.t. -Lipschitz losses can be converted to a bound on the misclassification error rate in terms of the average -margin error on the training data (see Bartlett et al. (2017, Section 3.1) for a discussion). Also, can be viewed as the “maximal” margin attainable over the input domain, since .
2 Applications of Thm. 5
In this section we exemplify how Thm. 5 can be used to obtain depth-independent bounds on the sample complexity of various classes of neural networks. The general technique is as follows: First, we prove a bound on , which generally depends on the depth , and scales as for some . Then, we plug it into Thm. 5, and utilize the following lemma to tune appropriately:
For any , and , it holds that
We begin with proving a depth-independent version of Thm. 1. That theorem implies that for the class of depth- neural networks with Frobenius norm bounds (up to and including ),
Plugging this into Thm. 5, and using Lemma 3, it is straightforward to derive the following corollary (see Sec. 7 for a formal derivation):
where .
Ignoring logarithmic factors and replacing the by its first argument, the bound in the corollary is at most
Assuming and are bounded by a constant, we get a bound which does not depend on the width or depth of the network: In other words, it is possible to make this bound smaller than any fixed , with a sample size independent of the network’s size. On the other hand, the bound in Corollary 1 is also bounded by
which is the bound one would get from an immediate application of Thm. 1, and implies that the asymptotic rate (as a function of ) is still maintained. As discussed in the introduction, the assumption that is a constant is certainly a strong one in practice, but to the best of our knowledge, is the first norm-based assumption which leads to size independence.
Next, we apply Thm. 5 to the results in Bartlett et al. (2017), which as discussed in the introduction, provide a depth-dependent bound using a different set of norms. Specifically, they obtain the following intermediary result in deriving their generalization bound:
Let be the hypothesis class of depth-, width- real-valued networks on , using -Lipschitz activation functions, given by
for some fixed parameters . Then the Rademacher complexity is upper-bounded by
As discussed in the introduction, can never be smaller than , hence the bound scales at least as . However, using the bound above together with Thm. 5 and Lemma 3, we can get the following corollary (where for simplicity, we assume that for all are uniformly bounded by some ):
where .
As before, by replacing the by its first argument, we get a bound which is fully independent of the network size, assuming the norms are suitably bounded. To give a concrete example, if we take (so that the constraints correspond to the Frobenius norm), and ignore lower-order logarithmic factors, we get a bound scaling as
In contrast, a direct application of Thm. 6 in the same setting leads to a bound of
Finally, we note that since the Eq. (3), based on a PAC-Bayes analysis, is always weaker than Eq. (2) (as noted in Bartlett et al. (2017)), Corollary 2 also gives a size-independent version of Eq. (3).
A Lower Bound for Schatten Norms
In this section, we present a lower bound on the Rademacher complexity, for the class of neural networks with parameter matrices of bounded Schatten norms. The formal result is the following:
This theorem strengthens Theorem 3.6 in Bartlett et al. (2017), in the sense that they only considered the case , and did not have a dependence on . On the other hand, they consider bounds which hold for any choice of , while we consider bounds uniform over for simplicity. Moreover, for network depths larger than , our construction requires a non element-wise activation function. The lower bound has the following implications:
Like Bartlett et al. (2017), the theorem implies that by controlling just the norms of each parameter matrix, a dependence on the product of the norms is generally inevitable.
For , we see that there is an inevitable factor in the bound, which implies that controlling the spectral norm is insufficient to get size-independent bounds (at least, independent of the width ). More generally, any Schatten -norm control with will be insufficient to get such size independence.
For (i.e. Frobenius norm bounds ), the lower bound becomes size-independent, and on the order of . The dependence on is similar to our upper bound in Corollary 1 up to logarithmic factors (although the dependence on is worse).
Additional Remarks
So far we have proved upper bounds on the empirical Rademacher complexity of a fixed class of neural networks, of the form
for some complexity measure and a parameter . These imply high-probability learning guarantees for algorithms which return predictors in . However, in the context of norm-based constraints, practical algorithms for neural networks usually perform unconstrained optimization, and therefore are not guaranteed a-priori to return a predictor in some fixed . Fortunately, it is straightforward to convert these bounds into probabilistic guarantees for any neural network , with the bound scaling appropriately with the complexity of the particular network. We note that such post-hoc guarantees have also been stated in the context of some previous sample complexity bounds for neural networks (e.g., Bartlett et al. (2017); Neyshabur et al. (2017)). It is achieved, for instance, by a union bound over, say, a doubling scale of the complexity. We refer to the proof of the margin bound of Koltchinskii and Panchenko (2002, Theorem 2) for an example of this technique.
2 Complexity of Lipschitz Networks
Taking this to the extreme, we can also bound the complexity of neural networks computing Lipschitz functions, by studying the complexity of all Lipschitz functions over the domain . It is easily verified that in our setting, if we consider the class of depth- networks, where each parameter matrix has spectral norm at most , then the network must be -Lipschitz. Using well-known estimates of the covering numbers of Lipschitz functions over , we get that
Proofs
We first prove Lemma 2. Letting denote the -th row of a matrix , we have
Since , the left-hand side of Eq. (11) is upper bounded by
and the proof is concluded exactly as in Lemma 1 by appealing to Ledoux and Talagrand (1991).
We now turn to Thm. 2, whose proof is rather similar to that of Thm. 1. Fixing to be chosen later, the Rademacher complexity can be upper bounded as
Applying the same argument as in the proof of Thm. 1, and using Lemma 2, we can upper bound the above by
where . Letting denote the -th coordinate of , and using symmetry, the expectation inside the log can be re-written as
where in the last step we used the fact that . Further upper bounding this by and plugging back to Eq. (13), we get
Choosing , we can upper bound the above by
2 Proof of Thm. 3
The proof will build on the following few technical lemmas.
which equals . ∎
By a simple calculation, we have that the Lipschitz constant of the function is at most .
Assume for now that . By definition, we have
The Lipschitz constant of the function is at most , and the norm of is at most . Therefore, for any ,
from which the result follows after a simplification. The cases and are handled in exactly the same manner. ∎
Suppose that is such that and . Then for any ,
Fixing some , and using the stated assumptions as well as the fact that for any , we have
Taking the -th root from both sides, the result follows. ∎
With these lemmas in hand, we can now turn to prove Thm. 3. A direct application of Lemma 6 implies that for any ,
Substituting Eq. (14) into Eq. (15), we get that
Suppose for now that is such that . Using the fact that for any , it follows that the above is at most
3 Proof of Thm. 4
To prove the theorem, we use a straightforward covering number argument, beginning with a few definitions.
Given any function class , a metric on the elements of , and , we let the covering number denote the minimal number of functions in , such that for all , . In particular, fix some set of data points , and define the empirical distance
Also, given a function class and , we let
denote the (empirical) Gaussian complexity of , where are i.i.d. standard Gaussian random variables. It is well known that and are equivalent up to a factor (Ledoux and Talagrand, 1991, pg. 97). By Sudakov’s minoration theorem (see Theorem 3.18 in Ledoux and Talagrand (1991)), we have that for all
With these definitions in hand, we turn to prove the theorem. We first note that is equivalent to the class , and therefore
again for some numerical constant . The first inequality follows from the fact that for any functions , it holds that , so it is enough to upper bound . To do so, we first notice that the range of any is in . Discretize into a two-dimensional grid , where
Given any , construct the piecewise-linear function as follows: For any input , let be the point in nearest to (breaking ties arbitrarily), and let the rest of be constructed as a linear interpolation of these points on . It is easily verified that . Moreover, note that for two neighboring points in , the points on must be neighboring or the same. Therefore, each such function can be parameterized by a vector of the form , which specifies whether (starting from the origin) goes up, down, or remains the same on each of its linear segments. The number of such functions is at most , and therefore . Recalling that majorizes , we get Eq. (18).
To see this, pick any and , and let be the respective closest functions in the cover of and (at scale ). By the triangle inequality and the easily verified fact that is -Lipschitz, we have
Therefore, we can cover (at scale ) by taking for all possible choices of from the covers of (at scale ), leading to Eq. (19).
Combining Eq. (16), Eq. (18) and Eq. (19), we get that
for some numerical constant . Finally, we use Dudley’s entropy integral, which together with the equation above, implies the following for some numerical constant (possibly changing from row to row):
Choosing in particular , we get the upper bound
for some . Plugging this into Eq. (7.3), and upper bounding by (see (Ledoux and Talagrand, 1991)), the result follows.
4 Proof of Thm. 5
We first need the following lemma, which bounds the empirical Rademacher complexity of the union of a collection of bounded function classes.
so satisfies a bounded differences assumption with variance factor . By McDiarmid’s inequality (Theorem 6.2, Boucheron et al. (2013)) it follows that for ,
(The same inequality, up to a constant factor, also follows directly from Theorem 4.7 in Ledoux and Talagrand (1991).) A union bound then shows that for ,
We next continue with the proof of Thm. 5. It is enough to prove the bound for any fixed , and then take the infimum over any such .
This function is equivalent to the composition of the function
Notice that for each , all functions of have output is bounded in ). Recall also that is the class consisting of real-valued -Lipschitz functions such that . As a result, we can apply Thm. 4 and obtain that for ,
Notice that all functions in have output bounded in , where
By Lemma 7, for an appropriate constant ,
for an appropriate constant . As mentioned at the beginning of the proof, this upper bound holds for any fixed , from which the result follows using the assumption that .
5 Proof of Lemma 3
We will show that for any as stated in the lemma, there always exists a choice of such that
Since the left hand side is also trivially at most , the result follows. We prove this inequality by a case analysis:
If , pick , in which case
If , it follows that
6 Proof of Corollary 1
Next, we plug Eq. (12) into Thm. 5. We use , let each be the space of all matrices, and choose for all , noting that . Since for all , it follows that
7 Proof of Corollary 2
where , , and (note that we use here instead of so the conditions of Lemma 3, to be used shortly, will be satisfied). As in Corollary 1, the term from Thm. 5 is absorbed into the term in the minimization over in the above equation.
8 Proof of Thm. 7
In particular, by choosing for all , we can lower bound the above by
and since by its definition, we get a lower bound of
Taking the best of this lower bound and the lower bound in Eq. (23), the result follows.
Acknowledgements
We thank Ziwei Ji and Matus Telgarsky for pointing that an additional union bound is required in the proof of Thm. 5, resulting in an extra logarithmic factor, as well as Pritish Kamath for pointing out a bug in the proof of Theorem 7, resulting in a slight change to the construction. Noah Golowich is grateful for research funding from Harvard University, including the Herchel Smith and PRISE fellowships.