Stronger generalization bounds for deep nets via a compression approach
Sanjeev Arora, Rong Ge, Behnam Neyshabur, Yi Zhang
Introduction
A mystery about deep nets is that they generalize (i.e., predict well on unseen data) despite having far more parameters than the number of training samples. One commonly voiced explanation is that regularization during training –whether implicit via use of SGD Neyshabur et al. (2015c); Hardt et al. (2016) or explicit via weight decay, dropout Srivastava et al. (2014), batch normalization Ioffe and Szegedy (2015), etc. –reduces the effective capacity of the net. But Zhang et al. (2017) questioned this received wisdom and fueled research in this area by showing experimentally that standard architectures using SGD and regularization can still reach low training error on randomly labeled examples (which clearly won’t generalize).
Clearly, deep nets trained on real-life data have some properties that reduce effective capacity, but identifying them has proved difficult —at least in a quantitative way that yields sample size upper bounds similar to classical analyses in simpler models such as SVMs Bartlett and Mendelson (2002); Evgeniou et al. (2000); Smola et al. (1998) or matrix factorization Fazel et al. (2001); Srebro et al. (2005).
Qualitatively Hochreiter and Schmidhuber (1997); Hinton and Van Camp (1993) suggested that nets that generalize well are flat minima in the optimization landscape of the training loss and Hinton and Van Camp (1993) further discusses the connections to Minimum Description Length principle for generalization. Recently Keskar et al. (2016) show using experiments with different batch-sizes that sharp minima do correlate with higher generalization error. A quantitative version of “flatness” was suggested in (Langford and Caruana, 2001): the net’s output is stable to noise added to the net’s trainable parameters. Using PAC-Bayes bound (McAllester, 1998, 1999) this noise stability yielded generalization bounds for fully connected nets of depth . The theory has been extended to multilayer fully connected nets (Neyshabur et al., 2017b), although thus far yields sample complexity bounds much worse than naive parameter counting. (Same holds for the earlier Bartlett and Mendelson (2002); Neyshabur et al. (2015b); Bartlett et al. (2017); Neyshabur et al. (2017a); Golowich et al. (2017); see Figure 4). Another notion of noise stability —closely related to dropout and batch normalization—is stability of the output with respect to the noise injected at the nodes of the network, which was recently shown experimentally (Morcos et al., 2018) to improve in tandem with generalization ability during training, and to be absent in nets trained on random data. Chaudhari et al Chaudhari et al. (2016) suggest adding noise to gradient descent to bias it towards finding flat minima.
While study of generalization may appear a bit academic — held-out data easily establishes generalization in practice— the ultimate hope is that it will help identify simple, measurable and intuitive properties of well-trained deep nets, which in turn may fuel superior architectures and faster training. We hope the detailed study —theoretical and empirical—in the current paper advances this goal.
A simple compression framework (Section 2) for proving generalization bounds, perhaps a more explicit and intuitive form of the PAC-Bayes work. It also yields elementary short proofs of recent generalization results (Section 2.2).
Identifying new form of noise-stability for deep nets: the stability of each layer’s computation to noise injected at lower layers. (Earlier papers worked only with stability of the output layer.) Figure 1 visualizes the stability of network w.r.t. Gaussian injected noise. Formal statements require a string of other properties (Section 3). All are empirically studied, including their correlation with generalization (Section 6).
Using the above properties to derive efficient and provably correct algorithms that reduce the effective number of parameters in the nets, yielding generalization bounds that: (a) are better than naive parameter counting (Section 6) (b) depend on simple, intuitive and measurable properties of the network (Section 4) (c) apply also to convolutional nets (Section 5) (d) empirically correlate with generalization (Section 6).
The main idea is to show that noise stability allows individual layers to be compressed via a linear-algebraic procedure Algorithm 1. This results in new error in the output of the layer. This added error is “gaussian-like” and tends to get attenuated as it propagates to higher layers.
Other related works. Dziugaite and Roy (2017) use non-convex optimization to optimize the PAC-Bayes bound get a non-vacuous sample bound on MNIST. While very creative, this provides little insight into favorable properties of networks. Liang et al. (2017) have suggested Fisher-Rao metric, a regularization based on the Fisher matrix and showed that this metric correlate with generalization. Unfortunately, they could only apply their method to linear networks. Recently Kawaguchi et al. (2017) connects Path-Norm Neyshabur et al. (2015a) to generalization. However, the proved generalization bound depends on the distribution and measuring it requires vector operations on exponentially high dimensional vectors. Other works have designed experiments to empirically evaluate potential properties of the network that helps generalizationArpit et al. (2017); Neyshabur et al. (2017b); Dinh et al. (2017). The idea of compressing trained deep nets is very popular for low-power applications; for a survey see (Cheng et al., 2018).
Finally, note that the terms compression and stability are traditionally used in a different sense in generalization theory Littlestone and Warmuth (1986); Kearns and Ron (1999); Shalev-Shwartz et al. (2010). Our framework is compared to other notions in the remarks after Theorem 2.1.
(Notice, the classification loss corresponds to .) Let denote empirical estimate of the margin loss. Generalization error is the difference between the two.
For most of the paper we assume that deep nets have fully connected layers, and use ReLU activations. We treat convolutional nets in Section 5. If the net has layers, we label the vector before activation at these layers by , , … for the layers where is the input to the net, also denoted simply . So where is the weight matrix of the th layer. (Here if is a vector applies the ReLU component-wise. The ReLU is allowed a trainable bias parameter, which is omitted from the notation because it has no effect on any calculations below.) We denote the number of hidden units in layer by and set . Let be the function calculated by the above network.
Stable rank of a matrix is , where denotes Frobenius norm and denotes spectral norm. Note that stable rank is at most (linear algebraic) rank.
For any two layer , denote by the operator for composition of these layers and be the Jacobian of this operator at input (a matrix whose is the partial derivative of the th output coordinate with respect to the ’th input input). Therefore, we have . Furthermore, since the activation functions are ReLU, we have .
Compression and Generalization
Our compression framework rests on the following obvious fact. Suppose the training data contains samples, and is a classifier from a complicated class (e.g., deep nets with much more than parameters) that incurs very low empirical loss. We are trying to understand if it will generalize. Now suppose we can compute a classifier with discrete trainable parameters much less than and which incurs similar loss on the training data as . Then must incur low classification error on the full distribution. This framework has the advantage of staying with intuitive parameter counting and to avoid explicitly dealing with the hypothesis class that includes (see note after Theorem 2.1). Notice, the mapping from to merely needs to exist, not to be efficiently computable. But in all our examples the mapping will be explicit and fairly efficient. Now we formalize the notions. The proofs are elementary via concentration bounds and appear in the appendix.
Let be a classifier and be a class of classifiers. We say is ()-compressible via if there exists such that for any , we have for all
We also consider a different setting where the compression algorithm is allowed a“helper string” , which is arbitrary but fixed before looking at the training samples. Often will contain random numbers. A simple example is to let be the random initialization used for training the deep net. Then compress the difference between the final weights and ; this can give better generalization bounds, similar to Dziugaite and Roy (2017). Other nontrivial examples appear later.
Suppose is a class of classifiers indexed by trainable parameters and fixed strings . A classifier is ()-compressible with respect to using helper string if there exists such that for any , we have for all
Suppose where is a set of parameters each of which can have at most discrete values and is a helper string. Let be a training set with samples. If the trained classifier is -compressible via with helper string , then there exists with high probability over the training set,
Remarks: (1) The framework proves the generalization not of but of its compression . (An exception is if the two are shown to have similar loss at every point in the domain, not just the training set. This is the case in Theorem 2.2.) (2) The previous item highlights how our framework steps away away from uniform convergence framework, e.g., covering number arguments Dudley (2010); Anthony and Bartlett (2009). There, one needs to fix a hypothesis class independent of the training set. By contrast we have no hypothesis class, only a single neural net that has some specific properties (described in Section 3) on a single finite training set. But if we can compress this specific neural net to a simpler neural nets with fewer parameters then we can use covering number argument on this simpler class to get the generalization of the compressed net. (3) Issue (1) exists also in standard PAC-Bayes framework for deep nets (see tongue-in-cheek title of (Langford and Caruana, 2001)). They yield generalization bounds not for but for a noised version of (i.e., net given by , where is parameter vector of and is a noise vector). For us issue (1) could be fixed by showing that if satisfies the properties of Section 3 on training data then it satisfies them on the entire domain. This is left for future work.
A classifier with margin can be compressed to one that has only non-zero entries. For each coordinate , toss a coin with and if it comes up heads set the coordinate to equal to (see Algorithm 2 in supplementary material). This yields a vector with only nonzero entries such that for any vector , with reasonable probability , so and will make the same prediction. We can then apply Theorem 2.1 on a discretized version of to show that the sparsified classifier has good generalization with samples.
This compressed classifier works correctly for a fixed input with good probability but not high probability. To fix this, one can recourse to the “compression with fixed string” model. The fixed string is a random linear transformation. When applied to unit vector , it tends to equalize all coordinates and the guarantee can hold with high probability. This random linear transformation can be fixed before seeing the training data. Similar approach was discussed by Blum (2006) for linear classifiers. See Section A.2 in supplementary material for more details.
2 Example 2: Existing generalization bounds
Our compression framework gives easy and short proof of the generalization bounds of a recent paper; see appendix for slightly stronger result of Bartlett et al. (2017).
(Neyshabur et al. (2017a)) For a deep net with layers and output margin on a training set , the generalization error can be bounded by
The second part of this expression () is sum of stable ranks of the layers, a natural measure of their true parameter count. The first part () is related to the Lipschitz constant of the network, namely, the maximum norm of the vector it can produce if the input is a unit vector. The Lipschitz constant of a matrix operator is just its spectral norm . Since the network applies a sequence of matrix operations interspersed with ReLU, and ReLU is -Lipschitz we conclude that the Lipschitz constant of the full network is at most
To prove Theorem 2.2 we use the following lemma to compress the matrix at each layer to a matrix of smaller rank. Since a matrix of rank can be expressed as the product of two matrices of inner dimension , it has parameters (instead of the trivial ). (Furthermore, the parameters can be discretized via trivial rounding to get a compression with discrete parameters as needed by Definition 1.)
Let be the rank of . By construction, the maximum singular value of is at most . Since the remaining singular values are at least , we have .∎
For each replace layer by its compression using the above lemma, with . How much error does this introduce at each layer and how much does it affect the output after passing through the intermediate layers (and getting magnified by their Lipschitz constants)? Since has spectral norm (i.e., Lipschitz constant) at most , the error at the output due to changing layer in isolation is at most .
A simple induction (see Neyshabur et al. (2017a) if needed) can now show the total error incurred in all layers is bounded by . The generalization bound follows immediately from Theorem 2.1.
Noise stability properties of deep nets
This section introduces noise stability properties of deep nets that imply better compression (and hence generalization). They help overcome the pessimistic error analysis of our proof of Theorem 2.2: when a layer was compressed, the resulting error was assumed to blow up in a worst-case manner according to the Lipschitz constant (namely, product of spectral norms of layers). This hurt the amount of compression achievable. The new noise stability properties roughly amount to saying that noise injected at a layer has very little effect on the higher layers. Our formalization starts with noise sensitivity, which captures how an operator transmits noise vs signal.
If is a mapping from real-valued vectors to real-valued vectors, and is some noise distribution then noise sensitivity of at with respect to , is
The noise sensitivity of with respect to on a set of inputs , denoted , is the maximum of over all inputs in .
To illustrate, we examine noise sensitivity of a matrix (i.e., linear mapping) with respect to Gaussian distribution. Low sensitivity turns out to imply that the matrix has some large singular values (i.e., low stable rank), which give directions that can preferentially carry the “signal” whereas noise attenuates because it distributes uniformly across directions.
The noise sensitivity of a matrix at any vector with respect to Gaussian distribution is exactly , and at least its stable rank.
Thus noise sensitivity at is , which is at least the stable rank since . ∎
The above proposition suggests that if a vector is aligned to a matrix (i.e. correlated with high singular directions of ), then matrix becomes less sensitive to noise at . This intuition will be helpful in understanding the properties we define later to formalize noise stability.
The above discussion motivates the following approach. We compress each layer by an appropriate randomized compression algorithm, such that the noise/error in its output is “Gaussian-like”. If layers and higher have low sensitivity to this new noise, then the compression can be more extreme producing much higher noise. We formalize this idea using Jacobian , which describes instantaneous change of under infinitesimal perturbation of .
Now we formalize the error-resilience properties. Section 6 reports empirical findings about these properties. The first is cushion, to be thought of roughly as reciprocal of noise sensitivity. We first formalize it for single layer.
The layer cushion of layer is similarly defined to be the largest number such that for any , .
Intuitively, cushion considers how much smaller the output is compared to the upper bound . Using argument similar to Proposition 3.1, we can see that is equal to the noise sensitivity of matrix at input with respect to Gaussian noise .
For any two layers , we define the interlayer cushion as the largest number such that for any :
Furthermore, for any layer we define the minimal interlayer cushion as Note that and .
Since is a linear transformation, a calculation similar to Proposition 3.1 shows that its noise sensitivity at with respect to Gaussian distribution is at most .
The next property quantifies the intuitive observation on the learned networks that for any training data, almost half of the ReLU activations at each layer are active. If the input to the activations is well-distributed and the activations do not correlate with the magnitude of the input, then one would expect that on average, the effect of applying activations at any layer is to decrease the norm of the pre-activation vector by at most some small constant factor.
The activation contraction is defined as the smallest number such that for any layer and any ,
We discussed how the interlayer cushion captures noise-resilience of the network if it behaves linearly, namely, when the set of activated ReLU gates does not change upon injecting noise. In general the activations do change, but the deviation from linear behavior is bounded for small noise vectors, as quantified next.
Let be the noise generated as a result of substituting weights in some of the layers before layer using Algorithm 1. We define interlayer smoothness to be the smallest number such that with probability over noise for any two layers any :
In order to understand the above condition, we can look at a single layer case where :
where is the entry-wise product operator and . Since the activation function is ReLU, and disagree whenever the perturbation has the opposite sign and higher absolute value compared to the input and hence .
Let us first see what happens if the perturbation is adversarially aligned to the weights:
where is the stable rank of layer . Therefore the interlayer smoothness from layer to layer is at least . However, the noise generated from Algorithm 1 has similar properties to Gaussian noise (see Lemma 2). If behaves similar to Gaussian noise, then and therefore is as high as . Since the layer cushion of networks trained on real data is much more than that of networks with random weights, is greater than one in this case. Another observation is that in practice, the noise is well-distributed and only a small portion of activations change from active to inactive and vice versa. Therefore, we can expect to be smaller than which further improves the interlayer smoothness. This appeared in Neyshabur et al. (2017b) that showed for one layer we can even use as the RHS of interlayer smoothness. Our current proof requires to be of order , this requirement can be removed (with appear in sample complexity) if we make the stronger assumption that the RHS is a lower order term in .
In general, for a single layer, captures the ratio of input/weight alignment to noise/weight alignment. Since the noise behaves similar to Gaussian, one expects this number to be greater than one for a single layer. When , the weights and activations create more dependencies. However, since these dependences are applied on both noise and input, we again expect that if the input is more aligned to the weights than noise, this should not change in higher layers. In Section 6, we show that the interlayer smoothness is indeed good: is a small constant.
Fully Connected Networks
We prove generalization bounds using for fully connected multilayer nets. Details appear in Appendix Section B.
where , , and are layer cushion, interlayer cushion, activation contraction and interlayer smoothness defined in Definitions 4,5,6 and 7 respectively.
To prove this we describe a compression of the net with respect to a fixed (random) string. In contrast to the deterministic compression of Lemma 1, this randomized compression ensures that the resulting error in the output behaves like a Gaussian. The proofs are similar to standard JL dimension reduction.
Note that the helper string of random matrices ’s were chosen and fixed before training set was picked. Each weight matrix is thus represented as only real numbers for .
Lemma 2 can be used to upper bound the change in the network output after compressing a single layer if the activation patterns remain the same. For any layer, in the lemma statement take to be the input to the layer, to be the layer weight matrix, and to be the Jacobian of the network output with respect to the layer output. Network output before and after compression can then be calculated by the matrix products and respectively. Hence, the lemma bounds the distance between network output before and after compression.
Next Lemma bounds the number of parameters of the compressed network resulting from applying Algorithm 1 to all the layer matrices of the net. The proof does induction on the layers and bounds the effect of the error on the output of the network using properties defined in Section 3.1.
where , , and are layer cushion, interlayer cushion, activation contraction and interlayer smoothness defined in Definitions 4,5,6 and 7 respectively.
(i) Empirically it has been observed that deep net training introduces fairly small changes to parameters as compared to the (random) initial weights Dziugaite and Roy (2017). We can exploit this by incorporating the random initial weights into the helper string and do the entire proof above not with the layer matrices but only the difference from the initial starting point. Experiments in Section 6 show this improves the bounds. (ii) Cushions and other quantities defined earlier are data-dependent, and required to hold for the entire training set. However, the proofs go through if we remove say fraction of outliers that violate the definitions; this allows us to use more favorable values for cushion etc. and lose an additive factor in the generalization error.
Convolutional Neural Networks
Now we sketch how to provably compress convolutional nets. (Details appear in Section C of supplementary.) Intuitively, this feels harder because the weights are already compressed— they’re shared across patches!
where , , , and are layer cushion, interlayer cushion, activation contraction, interlayer smoothness and well-distributed Jacobian defined in Definitions 4,8,6, 7 and 9 respectively. Furthermore, and are stride and filter width in layer .
Let’s realize that obvious extensions of earlier sections fail. Suppose layer of the neural network is an image of dimension and each pixel has channels, the size of the filter at layer is with stride . The convolutional filter has dimension . Applying matrix compression (Algorithm 1) independently to each copy of a convolutional filter makes number of new parameters proportional to , a big blowup.
Compressing a convolutional filter once and reusing it in all patches doesn’t work because the interlayer analysis implicitly requires the noise generated by the compression to behave similar to a spherical Gaussian, but the shared filters introduce correlations. Quantitatively, using the fully connected analysis would require the error to be less than interlayer cushion value (Definition 5) which is at most , and this can never be achieved from compressing matrices that are far smaller than to begin with.
We end up with a solution in between fully independent and fully dependent: p-wise independence. The algorithm generates -wise independent compressed filters for each convolution location . It results in times more parameters than a single compression. If grows logarithmically with relevant parameters, the filters behave like fully independent filters. Using this idea we can generalize the definition of interlayer margin to the convolution setting:
For any two layers , we define the interlayer cushion as the largest number such that for any :
Furthermore, for any layer we define the minimal interlayer cushion as Note that and .
Recall that interlayer cushion is related to the noise sensitivity of at with respect to Gaussian distribution . When we consider applied to a noise , if different pixels in are independent Gaussians, then we can indeed expect , which explains the extra factor in Definition 8 compared to Definition 5. The proof also needs to assume —in line with intuition behind convolution architecture— that information from the entire image field is incorporated somewhat uniformly across pixels. It is formalized using the Jacobian which gives the partial derivative of the output with respect to pixels at previous layer.
Empirical Evaluation
We study noise stability properties (defined in Section 3) of an actual trained deep net, and compute a generalization bound from Theorem 5.1. Experiments were performed by training a VGG-19 architecture Simonyan and Zisserman (2014) and a AlexNet Krizhevsky et al. (2012) for multi-class classification task on CIFAR-10 dataset. Optimization used SGD with mini-batch size 128, weight decay 5e-4, momentum and initial learning rate , but decayed by factor 2 every 30 epochs. Drop-out was used in fully-connected layers. We trained both networks for 299 epochs and the final VGG-19 network achieved training and validation accuracy while the AlexNet achieved training and validation accuracy. To investigate the effect of corrupted label, we trained another AlexNet, with training and validation accuracy, on CIFAR-10 dataset with randomly shuffled labels.
Our estimate of the sample complexity bound used exact computation of norms of weight matrices (or tensors) in all bounds(). Like previous bounds in generalization theory, ours also depend upon nuisance parameters like depth , logarithm of , etc. which probably are an artifact of the proof. These are ignored in the computation (also in computing earlier bounds) for simplicity. Even the generalization based on parameter counting arguments does have an extra dependence on depth Bartlett et al. (2017). A recent work, Golowich et al. (2017) showed that many such depth dependencies can be improved.
Section 3 identifies four properties in the networks that contribute to noise-stability: layer cushion, interlayer cushion, contraction, interlayer smoothness. Figure 2 plots the distribution of over different data points in the training set and compares to a Gaussian random network and then scaled properly. The layer cushion, which quantifies its noise stability, is drastically improved during the training, especially for the higher layers ( and higher) where most parameters live. Moreover, we observe that interlayer cushion, activation contraction and interlayer smoothness behave nicely even after training. These plots suggest that the driver of the generalization phenomenon is layer cushion. The other properties are being maintained in the network and prevent the network from falling prey to pessimistic assumptions that causes the other older generalization bounds to be very high. The assumptions made in section 3 (also in B.1) are verified on the VGG-19 net in appendix D.1 by histogramming the distribution of layer cushion, interlayer cushion, contraction, interlayer smoothness, and well-distributedness of the Jacobians of each layer of the net on each data point in the training set. Some examples are shown in Figure 2.
2 Correlation to generalization error
We evaluate our generalization bound during the training, see Figure 4, Right. After 120 epochs, the training error is almost zero but the test error continues to improve in later epochs. Our generalization bound continues to improve, though not to the same level. Thus our generalization bound captures part of generalization phenomenon, not all. Still, this suggests that SGD somehow improves our generalization measure implicitly. Making this rigorous is a good topic for further research.
Furthermore, we investigate effect of training with normal data and corrupted data by training two AlexNets respectively on original and corrupted CIFAR-10 with randomly shuffled labels. We identify two key properties that differ significantly between the two networks: layer cushion and activation contraction, see 4. Since our bound predicts larger cushion and lower contraction indicates better generalization, our bound is consistent w with the fact that the net trained on normal data generalizes ( validation accuracy).
3 Comparison to other generalization bounds
Table 1 shows the compressibility of various layers according to the bounds given by our theorem. Again, this is a qualitative due to ignoring nuisance factors, but it gives an idea of which layers are important in the calculation.
Conclusions
With a new compression-based approach, the paper has made progress on several open issues regarding generalization properties of deep nets. The approach also adapts specially to convolutional nets. The empirical verification of the theory in Section 6 shows a rich set of new properties satisfied by deep nets trained on realistic data, which we hope will fuel further theory work on deep learning, including how these properties play into optimization and expressivity. Another possibility is a more rigorous understanding of deep net compression, which sees copious empirical work motivated by low-power applications. Perhaps our p-wise independence idea used for compressing convnets (Section 5) has practical implications.
Acknowledgements
This research was done with support from NSF, ONR, Simons Foundation, Mozilla Research, and Schmidt Foundation.
References
Appendix A Complete proofs for Section 2
In this section we give proofs of the various statements.
We will first prove Theorem 2.1, which gives generalization guarantees for the compressed function.
(Theorem 2.1) The proof is a basic application of concentration bounds and union bound and appears in the appendix.
For each , the training loss is just the average of i.i.d. Bernoulli random variables with expectation equal to . Therefore by Chernoff bound we have
Therefore, suppose we choose , with probability at least we have . There are only different , hence by union bound, with probability at least , for all we have
Next, since is -compressible with respect to , there exists such that for and any we have
For these training examples, as long as the original function has margin at least , the new function classifies the example correctly. Therefore
Combining these two steps, we immediately get the result. ∎
Using the same approach, we can also prove the following Corollaries that allow the compression to fail with some probability
In the setting of Theorem 2.1, if the compression works for fraction of the training sample, then with high probability
The proof is using the same approach, except in this case we have
A.2 Example 1: Compress a Vector
This section gives detailed calculations supporting the first example in Section 2.
Algorithm 2 Vector-Compress(, ) returns a vector such that for any fixed (independent of choice of ), with probability at least , . The vector has at most non-zero entries with high probability.
On the other hand, the expected number of non-zero entries in is . By Chernoff bound we know with high probability the number of non-zero entries is at most . ∎
Combining the above two lemmas, we know there is a compression algorithm with discrete parameters that works with probability at least . Applying Corollary A.1 we get
For any number of sample , there is an efficient algorithm to generate a compressed vector , such that
Note that the rate we have here is not optimal as it depends on instead of . This is mostly due to Lemma 4 cannot give a high probability bound (indeed if we consider all the basis vectors as the test vectors , Vector-Compress is always going to fail on some of them).
To fix this problem we use a different algorithm that uses a helper string, see Algorithm 3
Note that in Algorithm 3, the parameters for the output are the ’s. The vectors ’s are sampled independently, and hence can be considered to be in the helper string.
For any fixed vector , Algorithm 3 produces a vector such that with probability at least , we have .
This is in fact a well-known corollary of Johnson-Lindenstrauss Lemma. Observe that
The discretization is easy to check as with high probability the matrix with columns ’s have spectral norm at most , so the vector before and after discretization can only change by . ∎
For any number of sample , there is an efficient algorithm with helper string to generate a compressed vector , such that
We will choose . By Lemma 7, we know there is a compression algorithm that works with probability , and has at most parameters. By Corollary A.1, we know
A.3 Proof for Generalization Bound in Neyshabur et al. [2017a]
We gave a compression in Lemma 1, the discretization in this case is trivial just by rounding the weights to nearest multiples of . The following lemma from Neyshabur et al. [2017a] (based on a simple induction of the noise) shows how the noises from different layers add up.
Let be a -layer network with weights . Then for any input , weights and , if for any layer , , then we have:
Compressing each layer with ensures . Since each has rank , the total number of parameters of the compressed network will be . Therefore we can apply Theorem 2.1 to get the generalization bound.
Appendix B Complete Proofs for Section 4
We discussed and verified several conditions in Section 3. Here, we formally state these conditions:
Layer cushion (): For any layer , we define the layer cushion as the largest number such that for any :
Interlayer cushion (): For any two layers , we define interlayer cushion as the largest number such that for any :
Furthermore, we define minimal interlayer cushion .
Activation contraction (): The activation contraction is defined as the smallest number such that for any layer and any ,
Interlayer smoothness (): Interlayer smoothness is defined the smallest number such that with probability over noise for any two layers any :
B.2 Proofs
(of Lemma 2) For any fixed vectors , we have
This is exactly the same as the case of Johnson-Lindenstrauss transformation. By standard concentration inequalities we know
Now for any pair of matrix/vector , let be the -th row of , by union bound we know with probability at least for all we have . Since and , we immediately get . ∎
For the base case , since we are not perturbing the input, the inequality is trivial. Now assuming that the induction hypothesis is true for , we consider what happens at layer . Let be the result of Algorithm 1 on with and . We can now apply Lemma 2 on the set which has size at most . Let , for any we have
The second term can be bounded by by induction hypothesis. Therefore, in order to prove the induction, it is enough to show that the first term is bounded by . We decompose the error into two error terms one of which corresponds to the error propagation through the network if activation were fixed and the other one is the error caused by change in the activations:
The first term can be bounded as follows:
Both terms can be bounded using interlayer smoothness condition of the network. First, notice that . Therefore by induction hypothesis . Now by interlayer smoothness property, . On the other hand, we also know , therefore , so again we have . Putting everything together completes the induction. ∎
where , , and are layer cushion, interlayer cushion, activation contraction and interlayer smoothness defined in Definitions 4,5,6 and 7 respectively.
Because of positive homogeneity of ReLU activations, we can assume without loss of generality that the network is balanced, i.e for any , (otherwise, one could rebalance the network before approximation and cushion in invariant to this rebalancing). Therefore, for any we have:
where the last inequality is because by Lemma 10, . Since the absolute value of each parameter in layer is at most , the logarithm of number of choices for each parameter in order to get -cover is which results in the covering number . Bounding the Rademacher complexity by Dudley entropy integral completes the proof. ∎
Appendix C Convolutional Neural Networks
In this section we give a compression algorithm for convolutional neural networks, and prove Theorem 5.1.
We start by developing some notations to work with convolutions and product of tensors. For simplicity of notation, for any , we define a product operator that given a th-order tensor and a order tensor with a matching dimensionality to the last -dimensions of , vectorizes the last dimensions of each tensor and returns a th order tensor as follows:
The ’s will be generated by Algorithm 4 and are -wise independent.
Let be the filter size and be the stride in layer of the convolutional network. Then for any , . Furthermore, since the activation functions are ReLU, we have .
In the rest of this section, we will first describe the compression algorithm Matrix-Project-Conv (Algorithm 4) and show that the output of this algorithm behaves similar to Gaussian noise (similar to Lemma 2). Then we will follow the same strategy as the feed-forward case and give the full proof.
The weights in convolutional neural networks have inherent correlation due to the architecture, as the weights are shared across different locations. However, in order to randomly compress the weight tensors, we need to break this correlation and try to introduce independent perturbations at every location. The procedure is described as Algorithm 4.
The goal of Algorithm 4 is to generate different compressed filters such that the total number of parameters is small, and at the same time ’s behave very similarly to applying Algorithm 1 for each location independently. We formalize these two properties in the following two lemmas:
Given a helper string that contains all of the matrices used in Algorithm 4, then it is possible to compute all of ’s based on . Since is a dimensional subspace has parameters.
By Algorithm 4 we know ’s are average of the matrices, and . Since , we know . Hence only depends on and . ∎
The random matrices ’s generated by Algorithm 4 are -wise independent. Moreover, for any , the marginal distribution of the matrices are i.i.d. Gaussian with variance 1 in every direction.
Take any subset of random matrices generated by Algorithm 4. We are going to consider the joint distribution of all the matrices used in generating these ’s ( of them) and the subspace .
Consider the following procedure: generate random matrices from , and let be the span of these vectors. By symmetry of Gaussian vectors, we know is a uniform random subspace of dimension .
Now we sample from the same distribution in a different order: first sample a uniform random subspace of dimension , then sample random Gaussian matrices within this subspace (which can be done by sample a Gaussian in the entire space and then project to this subspace). This is exactly the procedure described in Algorithm 4.
Therefore, the matrices used in generating these ’s are independent, as a result the ’s are also independent. The equivalence also shows that the marginal distributions of are i.i.d. spherical Gaussians. (Note that the reason this is limited to -wise independence is that if we look at more than random matrices from the subspace , they do not have the same distribution as Gaussian random matrices; the latter would span a subspace of dimension higher than .) ∎
Although the ’s are only -wise independent, when we can show that they behave similarly to fully independent random filters. We defer the technical concentration bounds to the end of this section (Section C.3).
Using this compression, we will prove that the noise generated at each layer behaves similar to a random vector. In particular it does not correlate with any fixed tensor, as long as the norms of the tensor is well-distributed:
Intuitively, is well-distributed if no spacial location of has a norm that is significantly larger than the average. Now we are ready to show the noise generated by this procedure behaves very similar to a random Gaussian (this is a generalization of Lemma 2):
We will first expand out :
In this expression, generates a 5-th order tensor (2 from and 3 from ), the order of dimensions is that takes coordinates number 3,4,5 (with dimensions ), the first dimension of takes the 2nd coordinate and the 4-th dimension of takes the 1st coordinate. The result of is a vector of dimension (because the first 4 dimensions are removed in the inner-product).
Now let us look at the terms in this sum, let . Let be the random matrices used when computing (for simplicity we omit the indices for ), then we have
By Lemma 12 we know ’s are -wise independent. Now we can apply Corollary C.2 to the sum of ’s. Let , then we know
Union bound over all pairs, we know with probability at least , we have for all .
Finally, we will try to relate with .
Here the first inequality is by the assumption that all ’s are -well-distributed. The second inequality is true because each entry in appears in at most entries of . Therefore, when is set to , we have as desired. ∎
C.2 Generalization Bounds for Convolutional Neural Networks
Next we will use Algorithm 4 to compress the neural network and prove generalization bounds. Similar to the feed-forward case, our first step is to show bound the perturbation of the output based on the noise introduced at each layer. This is captured by the following lemma (generalization of Lemma 3)
where , , , and are layer cushion, interlayer cushion, activation contraction, interlayer smoothness and well-distributedness of Jacobian defined in Definitions 4,8,6, 7 and 9 respectively.
(Note that although is now a 3-tensor, we still use to denote as we never use any other norm of .)
The second term can be bounded by by induction hypothesis. Therefore, in order to prove the induction, it is enough to show that the first term is bounded by . We decompose the error into two error terms one of which corresponds to the error propagation through the network if activation were fixed and the other one is the error caused by change in the activations:
The first term can be bounded as follows:
Because of positive homogeneity of ReLU activations, we can assume without loss of generality that the network is balanced, i.e for any , (otherwise, one could rebalance the network before approximation and cushion in invariant to this rebalancing). Therefore, for any we have:
where the last inequality is because by Lemma 10, . Since the absolute value of each parameter in layer is at most , the logarithm of number of choices for each parameter in order to get -cover is which results in the covering number . Bounding the Rademacher complexity by Dudley entropy integral completes the proof. ∎
Similar to the discussions at the end of Section 4, we can use distance to initialization and remove outliers. More concretely, we can get the following corollary
where , , and are layer cushion, interlayer cushion, activation contraction and interlayer smoothness defined in Definitions 4,8,6 and 7 respectively and measured on a fraction of the training set .
C.3 Concentration Inequalities for Sum of p𝑝p-wise Independent Variables
In this section we prove a technical lemma that shows the sum of -wise independent subexponential random variables have strong concentration properties. Previously similar results were known for Bernoulli random variables Pelekis and Ramon , the approach we take here is very similar.
The following lemma will imply concentration
Let be random variables where is -subexponential. Let , . If ’s are -wise independent
By Claim 1 below, we know this expectation is bounded by . The second part of the lemma follows immediately from Markov’s inequality. ∎
We do induction on . When this is clearly correct. Let , then we have
Suppose the claim is true for all , let , when we have
When , we know , hence by Binomial expansion we have
On the other hand, if , then we know all the terms in the summation and are bounded by , therefore
In both cases we prove , which finishes the induction. ∎
We also remark that Lemma 15 can be generalized to vectors
Let be random vectors where is -subexponential. Let , . If ’s are -wise independent, for any even
The proof is exactly the same as the proof of Lemma 15. When ’s are vectors we get exactly the same terms, except the terms have pair-wise inner-products. However, the inner-products so we only need to argue about the same inequality for ’s. ∎