FANTASTIC GENERALIZATION MEASURES
Year: 2020

Abstract:
Generalization of deep networks has lately been of great interest, resulting in a number of theoretically and empirically motivated complexity measures. However, most papers proposing such measures study only a small set of models, leaving open the question of whether the conclusion drawn from those experiments would remain valid in other settings. We present the first large scale study of generalization in deep networks. We investigate more then 40 complexity measures taken from both theoretical bounds and empirical studies. We train over 10,000 convolutional networks by systematically varying commonly used hyperparameters. Hoping to uncover potentially causal relationships between each measure and generalization, we analyze carefully controlled experiments and show surprising failures of some measures as well as promising measures for further research.

heading: 1 INTRODUCTION
text: Deep neural networks have seen tremendous success in a number of applications, but why (and how well) these models generalize is still a mystery (Neyshabur et al., 2014; Zhang et al., 2016; Recht et al., 2019). It is crucial to better understand the reason behind the generalization of modern deep learning models; such an understanding has multiple benefits, including providing guarantees for safety-critical scenarios and the design of better models. A number of papers have attempted to understand the generalization phenomenon in deep models from a theoretical perspective e.g. (Neyshabur et al., 2015b; Bartlett et al., 2017; Neyshabur et al., 2018a; Golowich et al., 2017; Arora et al., 2018; Nagarajan and Kolter, 2019a; Wei and Ma, 2019a; Long and Sedghi, 2019). The most direct and principled approach for studying generalization in deep learning is to prove a generalization bound; typically an upper bound on the test error based on some quantity that can be calculated on the training set. Unfortunately, finding tight bounds has proven to be an arduous undertaking. While encouragingly Dziugaite and Roy (2017) showed that PAC-Bayesian bounds can be optimized to achieve a reasonably tight generalization bound, current bounds are still not tight enough to accurately capture the generalization behavior. Others have proposed more direct empirical ways to characterize generalization of deep networks without attempting to deriving bounds (Keskar et al., 2016; Liang et al., 2017). However, as pointed by Dziugaite and Roy (2017), empirical correlation does not necessarily translate to a casual relationship between a measure and generalization.
A core component in (theoretical or empirical) analysis of generalization is the notion of complexity measure; a quantity that monotonically relates to some aspect of generalization. More specifically, lower complexity should often imply smaller generalization gap. A complexity measure may depend on the properties of the trained model, optimizer, and possibly training data, but should not have access to a validation set. Theoretically motivated complexity measures such as VC-dimension, norm of parameters, etc., are often featured as the major components of generalization bounds, where the monotonic relationship between the measures and generalization is mathematically established. In contrast, empirically motivated complexity measures such as sharpness (Keskar et al., 2016) are justified by experimentation and observation. In this work, we do not need to distinguish between theoretically vs empirically motivated measures, and simply refer to both as complexity measures.
∗Contributed equally. †Work done as part of the Google AI Residency Program.
Despite the prominent role of complexity measures in studying generalization, the empirical evaluation of these measures is usually limited to a few models, often on toy problems. A measure can only be considered reliable as a predictor of generalization gap if it is tested extensively on many models at a realistic problem size. To this end, we carefully selected a wide range of complexity measures from the literature. Some of the measures are motivated by generalization bounds such as those related to VC-dimension, norm or margin based bounds, and PAC-Bayesian bounds. We further selected a variety of empirical measures such as sharpness (Keskar et al., 2016), Fisher-Rao norm (Liang et al., 2017) and path norms (Neyshabur et al., 2017).
In this study, we trained more than 10,000 models over two image classification datasets, namely, CIFAR-10 (Krizhevsky et al., 2014) and Street View House Numbers (SVHN) Netzer et al. (2011). In order to create a wide range of generalization behaviors, we carefully varied hyperparameters that are believed to influence generalization. We also selected multiple optimization algorithms and looked at different stopping criteria for training convergence. Details of all our measures and hyperparameter selections are provided in Appendix D. Training under all combination of hyperparameters and optimization resulted in a large pool of models. For any such model, we considered 40 complexity measures. The key findings that arise from our large scale study are summarized below:
1. It is easy for some complexity measures to capture spurious correlations that do not reflect causal insights about generalization; to mitigate that we propose a more rigorous method to study them.
2. Many norm-based measures not only perform poorly, but negatively correlate with generalization specifically when the optimization procedure injects some stochasticity. In particular, the generalization bound based on the product of spectral norms of the layers (similar to that of Bartlett et al. (2017)) has very strong negative correlation with generalization.
3. Sharpness-based measures like PAC-Bayesian bounds (McAllester, 1999) and the measure proposed by Keskar et al. (2016) perform best and seem promising candidates for further research.
4. Measures related to the optimization procedures such as the gradient noise and the speed of the optimization can be predictive of generalization.
Our findings on the relative success of sharpness-based and optimization-based complexity measures for predicting the generalization gap can provoke further study of these measures.

heading: 1.1 RELATED WORK
text: The theoretically motivated measures that we consider in this work belong to a few different families: PAC-Bayes (McAllester, 1999; Dziugaite and Roy, 2017; Neyshabur et al., 2017); VC-dimension (Vapnik and Chervonenkis, 1971); and norm-based bounds (Neyshabur et al., 2015b; Bartlett et al., 2017; Neyshabur et al., 2018a). The empirically motivated measures from prior literature that we consider are based on sharpness measure (Keskar et al., 2016); Fisher-Rao measure (Liang et al., 2017); distance of trained weights from initialization (Nagarajan and Kolter, 2019b) and path norm (Neyshabur et al., 2015a). Finally, we consider some optimization based measures based on the speed of the optimization algorithm as motivated by the work of (Hardt et al., 2015) and (Wilson et al., 2017a), and the magnitude of the gradient noise as motivated by the work of (Chaudhari and Soatto, 2018) and (Smith and Le, 2017).
A few papers have explored a large scale study of generalization in deep networks. Neyshabur et al. (2017) perform a small scale study of the generalization of PAC-Bayes, sharpness and a few different norms, and the generalization analysis is restricted to correlation. Jiang et al. (2018) studied the role of margin as a predictor of the generalization gap. However, they used a significantly more restricted set of models (e.g. no depth variations), the experiments were not controlled for potential undesired correlation (e.g. the models can have vastly different training error) and some measures contained parameters that must be learned from the set of models. Novak et al. (2018) conducted large scale study of neural networks but they only looked at correlation of a few measures to generalization. In contrast, we study thousands of models, and perform controlled experiments to avoid undesired artificial correlations. Some of our analysis techniques are inspired by Neal (2019) who proposed the idea of studying generalization in deep models via causal graphs, but did not provide any details or empirical results connected to that idea. Our work focuses on measures that can be computed on a single model and compares a large number of bounds and measures across a much wider range of models in a carefully controlled fashion.

heading: 2 GENERALIZATION: WHAT IS THE GOAL AND HOW TO EVALUATE?
text: Generalization is arguably the most fundamental and yet mysterious aspect of machine learning. The core question in generalization is what causes the triplet of a model, optimization algorithm, and data properties1, to generalize well beyond the training set. There are many hypotheses concerning this question, but what is the right way to compare these hypotheses? The core component of each hypothesis is complexity measure that monotonically relates to some aspect of generalization. Here we briefly discuss some potential approaches to compare different complexity measures:
• Tightness of Generalization Bounds. Proving generalization bounds is very useful to establish the causal relationship between a complexity measure and the generalization error. However, almost all existing bounds are vacuous on current deep learning tasks (combination of models and datasets), and therefore, one cannot rely on their proof as an evidence on the causal relationship between a complexity measure and generalization currently2.
• Regularizing the Complexity Measure. One may evaluate a complexity measure by adding it as a regularizer and directly optimizing it, but this could fail due to two reasons. The complexity measure could change the loss landscape in non-trivial ways and make the optimization more difficult. In such cases, if the optimization fails to optimize the measure, no conclusion can be made about the causality. Another, and perhaps more critical, problem is the existence of implicit regularization of the optimization algorithm. This makes it hard to run a controlled experiment since one cannot simply turn off the implicit regularization; therefore, if optimizing a measure does not improve generalization it could be simply due to the fact that it is regularizing the model in the same way as the optimization is regularizing it implicitly.
• Correlation with Generalization Evaluating measures based on correlation with generalization is very useful but it can also provide a misleading picture. To check the correlation, we should vary architectures and optimization algorithms to produce a set of models. If the set is generated in an artificial way and is not representative of the typical setting, the conclusions might be deceiving and might not generalize to typical cases. One such example is training with different portions of random labels which artificially changes the dataset. Another pitfall is drawing conclusion from changing one or two hyper-parameters (e.g changing the width or batch-size and checking if a measure would correlate with generalization). In these cases, the hyper-parameter could be the true cause of both change in the measure and change in the generalization, but the measure itself has no causal relationship with generalization. Therefore, one needs to be very careful with experimental design to avoid unwanted correlations.
In this work we focus on the third approach. While acknowledging all limitations of a correlation analysis, we try to improve the procedure and capture some of the causal effects as much as possible through careful design of controlled experiments. Further, to evaluate the effectiveness of complexity measures as accurately as possible, we analyze them over sufficiently trained models with a wide range of variations in hyperparameters. For practical reasons, these models must reach convergence within a reasonable time budget. Details of the notations used are outlined in Appendix A.

heading: 2.1 TRAINING MODELS ACROSS HYPERPARAMETER SPACE
text: In order to create models with different generalization behavior, we consider various hyperparameter types, which are known or believed to influence generalization (e.g. batch size, dropout rate, etc.). Formally, denote each hyperparameter by θi taking values from the set Θi, for i = 1, . . . , n and n denoting the total number of hyperparameter types3. For each value of hyperparameters θ , (θ1, θ2, . . . , θn) ∈ Θ, where Θ , Θ1 × Θ2 × · · · × Θn, we train the architecture until the training loss (cross-entropy value) reaches a given threshold . See the Appendix C.2 for a discussion on the choice of the stopping criterion. Doing this for each hyper-parameter configuration θ ∈ Θ, we obtain a total of |Θ| models. The space Θ reflects our prior knowledge about a reasonable hyperparameter
1For example, it is expected that images share certain structures that allows some models (which leverage these biases) to generalize.
2See Dziugaite and Roy (2017) for an example of non-vacuous generalization bound and related discussions. 3In our analysis we use n = 7 hyperparameters: batch size, dropout probability, learning rate, network
depth, weight decay coefficient, network width, optimizer.
space, both in terms of their types and values. Regarding the latter, one could, for example, create Θi by grid sampling of a reasonable number of points within a reasonable range of values for θi.

heading: 2.2 EVALUATION CRITERIA

heading: 2.2.1 KENDALL’S RANK-CORRELATION COEFFICIENT
text: One way to evaluate the quality of a complexity measure µ is through ranking. Given a set of models resulted by training with hyperparameters in the set Θ, their associated generalization gap {g(θ) |θ ∈ Θ}, and their respective values of the measure {µ(θ) |θ ∈ Θ}, our goal is to analyze how consistent a measure (e.g. `2 norm of network weights) is with the empirically observed generalization. To this end, we construct a set T , where each element of the set is associated with one of the trained models. Each element has the form of a pair: complexity measure µ versus generalization gap g.
T , ∪θ∈Θ { ( µ(θ), g(θ) )} . (1)
An ideal complexity measure must be such that, for any pair of trained models, if µ(θ1) > µ(θ2), then so is g(θ1) > g(θ2). We use Kendall’s rank coefficient τ (Kendall, 1938) to capture to what degree such consistency holds among the elements of T .
τ(T ) , 1|T |(|T | − 1) ∑
(µ1,g1)∈T ∑ (µ2,g2)∈T \(µ1,g1) sign(µ1 − µ2 ) sign(g1 − g2) (2)
Note that τ can vary between 1 and −1 and attains these extreme values at perfect agreement (two rankings are the same) and perfect disagreement (one ranking is the reverse of the other) respectively. If complexity and generalization are independent, the coefficient becomes zero.

heading: 2.2.2 GRANULATED KENDALL’S COEFFICIENT
text: While Kendall’s correlation coefficient is an effective tool widely used to capture relationship between 2 rankings of a set of objects, we found that certain measures can achieve high τ values in a trivial manner – i.e. the measure may strongly correlate with the generalization performance without necessarily capturing the cause of generalization. We will analyze this phenomenon in greater details in subsequent sections. To mitigate the effect of spurious correlations, we propose a new quantity for reflecting the correlation between measures and generalization based on a more controlled setting.
None of the existing complexity measures is perfect. However, they might have different sensitivity and accuracy w.r.t. different hyperparameters. For example, sharpness may do better than other measures when only a certain hyperparameter (say batch size) changes. To understand such details, in addition to τ(T ), we compute τ for consistency within each hyperparameter axis Θi, and then average the coefficient across the remaining hyperparameter space. Formally, we define:
mi , |Θ1 × · · · ×Θi−1 ×Θi+1 × · · · ×Θn| (3)
ψi , 1
mi ∑ θ1∈Θ1 · · · ∑ θi−1∈Θi−1 ∑ θi+1∈Θi+1 · · · ∑ θn∈Θn τ ( ∪θi∈Θi{ ( µ(θ), g(θ) ) } ) (4)
The inner τ reflects the ranking correlation between the generalization and the complexity measure for a small group of models where the only difference among them is the variation along a single hyperparameter θi. We then average the value across all combinations of the other hyperparameter axis. Intuitively, if a measure is good at predicting the effect of hyperparameter θi over the model distribution, then its corresponding ψi should be high. Finally, we compute the average ψi of average across all hyperparamter axes, and name it Ψ:
Ψ , 1
n n∑ i=1 ψi (5)
If a measure achieves a high Ψ on a given hyperparameter distribution Θ, then it should achieve high individual ψ across all hyperparameters. A complexity measure that excels at predicting changes in a single hyperparameter (high ψi) but fails at the other hyperparameters (low ψj for all j 6= i) will not do well on Ψ. On the other hand, if the measure performs well on Ψ, it means that the measure can reliably rank the generalization for each of the hyper-parameter changes.
A thought experiment to illustrate why Ψ captures a better causal nature of the generalization than Kendall’s τ is as follows. Suppose there exists a measure that perfectly captures the depth of the network while producing random prediction if 2 networks have the same depth, this measure would do reasonably well in terms of τ but much worse in terms of Ψ. In the experiments we consider in the following sections, we found that such a measure would achieve overall τ = 0.362 but Ψ = 0.11.

heading: 2.2.3 CONDITIONAL INDEPENDENCE TEST: TOWARDS CAPTURING THE CAUSAL RELATIONSHIPS
text: Relying on correlation is intuitive but perhaps unsatisfactory. In our experiments, we change several hyper-parameters and assess the correlation between a complexity measure and generalization; however, changing the hyper-parameters can also be seen as interventions or randomized tests since they are chosen independently from any other variables, and we can use this observation to uncover causal structures. Specifically, we rely on the conditional independent test which measures the conditional mutual information between random variables. Details are outlined in Appendix B.

heading: 3 GENERATING A FAMILY OF TRAINED MODELS
text: We chose 7 common hyperparameter types related to optimization and architecture design, with 3 choices for each hyperparameter. We generated 37 = 2187 models that are trained on the CIFAR10 dataset. We analyze these 2187 models in the subsequent sections; however, additional results including repeating the experiments 5 times as well as training the models using SVHN dataset are presented4 in Appendix Section C.5. These additional experiments, which add up to more than 10,000 trained models, suggest that the observations we make here are robust to randomness, and, more importantly, captures general behaviors of image classification tasks.
We trained these models to convergence. Convergence criterion is chosen as when cross-entropy loss reaches the value 0.01. Any model that was not able to achieve this value of cross-entropy5 was discarded from further analysis. The latter is different from the DEMOGEN dataset (Jiang et al., 2018) where the models are not trained to the same cross-entropy. Putting the stopping criterion on the training loss rather than the number of epochs is crucial since otherwise one can simply use cross-entropy loss value to predict generalization. Please see Appendix Section C.2 for a discussion on the choice of stopping criterion.
To construct a pool of trained models with vastly different generalization behaviors while being able to fit the training set, we covered a wide range of hyperparameters for training. Our base model is inspired by the Network-in-Network (Gao et al., 2011). The hyperparameter categories we test on are: weight decay coefficient (weight decay), width of the layer (width), mini-batch size (batch size), learning rate (learning rate), dropout probability (dropout), depth of the architecture (depth) and the choice of the optimization algorithms (optimizer). We select 3 choices for each hyperparameter (i.e. |Θi| = 3). Please refer to Appendix C.3 for the details on the models, and Appendix C.1 for the reasoning behind the design choices.
Figure 1 shows summarizing statistics of the models in this study. On the left we show the number of models that achieve above 99% training accuracy for every individual hyperparameter choice. Since we have 37 = 2187 models in total, the maximum number of models for each hyperparameter type is 37−1 = 718; the majority of the models in our pool were able to reach this threshold. In the middle we show the distribution of the cross-entropy value over the entire training set. While we want the models to be at exactly 0.01 cross-entropy, in practice it is computationally prohibitive to constantly evaluate the loss over the entire training set; further, to enable reasonable temporal granularity, we estimate the training loss with 100 randomly sampled minibatch. These computational compromises result in long-tailed distribution of training loss centered at 0.01. As shown in Table 1, even such minuscule range of cross-entropy difference could lead to positive correlation with generalization, highlighting the importance of training loss as a stopping criterion. On the right, we show the distribution of the generalization gap. Notice while all the models’ training accuracy is above 0.99, there is a wide range of generalization gap, which is ideal for evaluating complexity measures.
4All the experiments reported in the main text have been repeated for 5 times. The mean (Table 9) is consistent with those presented in the main text and standard deviation (Table 10) is very small compared to the magnitude of the mean for all measures. Further, we also repeat the experiments once on the SVHN dataset (Table 7), whose results are also consistent with the observations made on CIFAR-10.
5In our analysis, less than 5 percent of the models do not reach this threshold.

heading: 4 PERFORMANCE OF COMPLEXITY MEASURES

heading: 4.1 BASELINE COMPLEXITY MEASURES
text: The first baseline we consider is performance of a measure against an oracle who observes the noisy generalization gap. Concretely, we rank the models based on the true generalization gap with some additive noise. The resulting ranking correlation indicates how close the performances of all models are. As the scale of the noise approaches 0, the oracle’s prediction tends towards perfect (i.e. 1). This baseline accounts for the potential noise in the training procedure and gives an anchor for gauging the difficulty of each hyperparameter type. Formally, given an arbitrary set of hyper-parameters Θ′, we define -oracle to be the expectation of τ or Ψ where the measure is {g(θ)+N (0, 2) |θ ∈ Θ′}. We report the performance of the noisy oracle in Table 1 for ∈ {0.02, 0.05}. For additional choices of please refer to Appendix C.5.
Second, to understand how our hyperparameter choices affect the optimization, we give each hyperparameter type a canonical order which is believed to have correlation with generalization (e.g. larger learning rate generalizes better) and measure their τ . The exact canonical ordering can be found in Appendix C.4. Note that unlike other measures, each canonical ordering can only predict generalization for its own hyperparameter type, since its corresponding hyperparameter remains fixed in any other hyperparameter type; consequently, each column actually represents different measure for the canonical measure row. Assuming that each canonical measure is uninformative of any other canonical measures, the Ψ criterion for each canonical measure is 17 of its performance on the corresponding hyperparameter type.
We next look at one of the most well-known complexity measures in machine learning; the VCDimension. Bartlett et al. (2019) proves bounds on the VC dimension of piece-wise linear networks with potential weight sharing. In Appendix D.1, we extend their result to include pooling layers and multi-class classification. We report two complexity measures based on VC-dimension bounds and parameter counting. These measures could be predictive merely when the architecture changes, which happens only in depth and width hyperparameter types. We observe that, with both types,
VC-dimension as well as the number of parameters are negatively correlated with generalization gap which confirms the widely known empirical observation that overparametrization improves generalization in deep learning.
Finally, we report the measures that only look at the output of the network. In particular, we look at the cross-entropy loss, margin γ, and the entropy of the output. These three measures are closely related to each other. In fact, the outcomes in Table 1 reflects this similarity. These results confirm the general understanding that larger margin, lower cross-entropy and higher entropy would lead to better generalization. Please see Appendix D.1.1 for definitions and more discussions on these measures.

heading: 4.2 SURPRISING FAILURE OF SOME (NORM & MARGIN)-BASED MEASURES
text: In machine learning, a long standing measure for quantifying the complexity of a function, and therefore generalization, is using some norm of the given function. Indeed, directly optimizing some of the norms can lead to improved generalization. For example, `2 regularization on the parameters of a model can be seen as imposing an isotropic Gaussian prior over the parameters in maximum a posteriori estimation. We choose several representative norms (or measures based on norms) and compute our correlation coefficient between the measures and the generalization gap of the model.
We study the following measures and their variants (Table 2): spectral bound, Frobenius distance from initialization, `2 Frobenius norm of the parameters, Fisher-Rao metric and path norm.
Spectral bound: The most surprising observation here is that the spectral complexity is strongly negatively correlated with generalization, and negatively correlated with changes within every hyperparameter type. Most notably, it has strong negative correlation with the depth of the network, which may suggest that the largest singular values are not sufficient to capture the capacity of the model. To better understand the reason behind this observation, we investigate using different components of the spectral complexity as the measure. An interesting observation is that the Frobenius distance to initialization is negatively correlated, but the Frobenius norm of the parameters is slightly positively correlated with generalization, which contradicts some theories suggesting solutions closer to initialization should generalize better. A tempting hypothesis is that weight decay favors solution closer to the origin, but we did an ablation study on only models with 0 weight decay and found that the distance from initialization still correlates negatively with generalization.
These observations correspond to choosing different reference matrices W0i for the bound: the distance corresponds to using the initialization as the reference matrices while the Frobenius norm of the parameters corresponds to using the origin as the reference. Since the Frobenius norm of the parameters shows better correlation, we use zero reference matrices in the spectral bound. This improved both τ and Ψ, albeit still negative. In addition, we extensively investigate the effect of different terms of the Spectral bound to isolate the effect; however, the results do not improve. These experiments can be found in the Appendix D.2.
Path norm: While path-norm is a proper norm in the function space but not in parameter space, we observe that it is positively correlated with generalization in all hyper-parameter types and achieves comparable τ (0.373) and Ψ (0.311).
Fisher-Rao metric: The Fisher-Rao metric is a lower bound (Liang et al., 2017) on the path norm that has been recently shown to capture generalization. We observed that it overall shows worse
correlation than the path norm; in particular, it is negatively correlated with the depth of the network, which contrasts with path norm that properly captures the effect of depth on generalization. A more interesting observation is that the Fisher-Rao metric achieves a positive Ψ = 0.154 but its τ = 0.078 is essentially at chance. This may suggest that the metric can capture a single hyper-parameter change but is not able to capture the interactions between different hyperparameter types.
Effect of Randomness: dropout and batch size (first 2 columns of Table 2) directly introduce randomness into the training dynamic. For batch size, we observed that the Frobenius displacement and spectral complexity both correlate negatively with the changes in batch size while the Frobenius norm of the parameters correlates positively with generalization. On the other hand, when changes happen to the magnitude dropout probability, we observed that all of the proper norms are negatively correlated with the generalization changes. Since increasing dropout usually reduces the generalization gap, this implies that increasing the dropout probability may be at least partially responsible for the growth in these norms. This is unexpected since increasing norm in principle implies higher model capacity which is usually more prone to overfitting.
The overall picture does not change much going from the ranking correlation to mutual information, with a notable exception where spectral complexity has the highest conditional mutual information compared to all the other measures. This is due to the fact that the conditional mutual information is agnostic to the direction of correlation, and in the ranking correlation, spectral complexity has the highest absolute correlation. While this view might seem contradictory to classical view as the spectral complexity is a complexity measure which should be small to guarantee good generalization, it is nonetheless informative about the generalization of the model. Further, by inspecting the conditional mutual information for each hyperparameter, we find that the majority of spectral complexity’s predictive power is due to its ability to capture the depth of the network, as the mutual information is significantly lower if depth is already observed.

heading: 4.3 SUCCESS OF SHARPNESS-BASED MEASURES
text: A natural category of generalization measures is centered around the concept of “sharpness” of the local minima, capturing the sensitivity of the empirical risk (i.e. the loss over the entire training set) to perturbations in model parameters. Such notion of stability under perturbation is captured elegantly by the PAC-Bayesian framework (McAllester, 1999) which has provided promising insights for studying generalization of deep neural networks (Dziugaite and Roy, 2017; Neyshabur et al., 2017; 2018a). In this sections, we investigate PAC-Bayesian generalization bounds and several of their variants which rely on different priors and different notions of sharpness (Table 3).
In order to evaluate a PAC-Bayesian bound, one needs to come up with a prior distribution over the parameters that is chosen in advance before observing the training set. Then, given any posterior distribution on the parameters which could depend on the training set, a PAC-Bayesian bound (Theorem 46) states that the expected generalization error of the parameters generated from the posterior can be bounded by the KL-divergence of the prior and posterior. The posterior distribution can be seen as adding perturbation on final parameters. Dziugaite and Roy (2017) shows contrary to other generalization bounds, it is possible to calculate non-vacuous PAC-Bayesian bounds by optimizing the bound over a large set of Gaussian posteriors. Neyshabur et al. (2017) demonstrates that when prior and posterior are isotropic Gaussian distributions, then PAC-Bayesian bounds are good measure of generalization on small scale experiments; see Eq (47).
PAC-Bayesian framework captures sharpness in the expected sense since we add randomly generated perturbations to the parameters. Another possible notion of sharpness is the worst-case sharpness where we search for the direction that changes the loss the most. This is motivated by (Keskar et al., 2016) where they observe that this notion would correlate with generalization in the case of different batch sizes. We can use PAC-Bayesian framework to construct generalization bounds for this worst-case perturbations as well. We refer to this worst case bound as the sharpness bound in Eq (50). The main component in both PAC-Bayes and worst-case sharpness bounds is the ratio of norm of parameters to the magnitude of the perturbation, where the magnitude is chosen to be the largest number such that the training error of the perturbed model is at most 0.1. While mathematically, the sharpness bound should always yield higher complexity than the PAC-Bayes bound, we observed that the former has higher correlation both in terms of τ and Ψ. In addition, we studied inverse of perturbation magnitude as a measure by removing the norm in the numerator to compare it with the bound. However, we did not observe a significant difference.

heading: 4.3.1 MAGNITUDE-AWARE PERTURBATION BOUNDS
text: Perturbing the parameters without taking their magnitude into account can cause many of them to switch signs. Therefore, one cannot apply large perturbations to the model without changing the loss significantly. One possible modification to improve the perturbations is to choose the perturbation magnitude based on the magnitude of the parameter. In that case, it is guaranteed that if the magnitude of perturbation is less than the magnitude of the parameter, then the sign of the parameter does not change. Following Keskar et al. (2016), we pick the magnitude of the perturbation with respect to the magnitude of parameters. We formalize this notion of importance based magnitude. Specifically, we derive two alternative generalization bounds for expected sharpness in Eq (55) and worst case sharpness in Eq (58) that include the magnitude of the parameters into the prior. Formally, we design α′ and σ′, respectively for sharpness and PAC-Bayes bounds, to be the ratio of parameter magnitude to the perturbation magnitude. While this change did not improve upon the original PAC-Bayesian measures, we observed that simply looking at 1/α′ has surprising predictive power in terms of the generalization which surpasses the performance of oracle 0.02. This measure is very close to what was originally suggested in Keskar et al. (2016). Its effectiveness is further corroborated by the conditional mutual information based metric, where we observed that 1/α′ has the highest mutual information with generalization among all hyperparameters and also overall.
4.3.2 FINDING σ
In case of models with extremely small loss, the perturbed loss should roughly increase monotonically with respect to the perturbation scale. Leveraging this observation, we design algorithms for computing the perturbation scale σ such that the first term on the RHS is as close to a fixed value as possible for all models. In our experiments, we choose the deviation to be 0.1 which translates to 10% training error. These search algorithms are paramount to compare measures between different models. We provide the detailed algorithms in the Appendix E. To improve upon our algorithms, one could try a computational approach similar to Dziugaite and Roy (2017) to obtain a numerically better bound which may result in stronger correlation. However, due to practical computational constraints, we could not do so for the large number of models we consider.

heading: 4.4 POTENTIAL OF OPTIMIZATION-BASED MEASURES
text: Optimization is an indispensable component of deep learning. Numerous optimizers have been proposed for more stable training and faster convergence. How the optimization scheme and speed of optimization influence generalization of a model has been a topic of contention among the deep learning community (Merity et al., 2017; Hardt et al., 2015). We study 3 representative optimizers Momentum SGD, Adam, and RMSProp with different initial learning rates in our experiments to thoroughly evaluate this phenomenon. We also consider other optimization related measures that are believed to correlate with generalization. These include (Table 4):
1. Number of iterations required to reach cross-entropy equals 0.1
2. Number of iterations required going from cross-entropy equals 0.1 to cross-entropy equals 0.01
3. Variance of the gradients after only seeing the entire dataset once (1 epoch)
4. Variance of the gradients when the cross-entropy is approximately 0.01
Number of Iterations: The number of iterations roughly characterizes the speed of optimization, which has been argued to correlate with generalization. For the models considered here, we observed that the initial phase (to reach cross-entropy value of 0.1) of the optimization is negatively correlated with the speed of optimization for both τ and Ψ. This would suggest that the difficulty of optimization during the initial phase of the optimization benefits the final generalization. On the other hand, the speed of optimization going from cross-entropy 0.1 to cross-entropy 0.01 does not seem to be correlated with the generalization of the final solution. Importantly, the speed of optimization is not an explicit capacity measure so either positive or negative correlation could potentially be informative.
Variance of Gradients: Towards the end of the training, the variance of the gradients also captures a particular type of “flatness” of the local minima. This measure is surprisingly predictive of the generalization both in terms of τ and Ψ, and more importantly, is positively correlated across every type of hyperparameter. To the best of our knowledge, this is the first time this phenomenon has been observed. The connection between variance of the gradient and generalization is perhaps natural since much of the recent advancement in deep learning such as residual networks (He et al., 2016) or batch normalization have enabled using larger learning rates to train neural networks. Stability with higher learning rates implies smaller noises in the minibatch gradient. With the mutual information metric, the overall observation is consistent with that of ranking correlation, but the final gradient noise also outperforms gradient noise at 1 epoch of training conditioned on the dropout probability. We hope that our work encourages future works in other possible measures based on optimization and during training.

heading: 5 CONCLUSION
text: We conducted large scale experiments to test the correlation of different measures with the generalization of deep models and propose a framework to better disentangle the cause of correlation from spurious correlation. We confirmed the effectiveness of the PAC-Bayesian bounds through our experiments and corroborate it as a promising direction for cracking the generalization puzzle. Further, we provide an extension to existing PAC-Bayesian bounds that consider the importance of each parameter. We also found that several measures related to optimization are surprisingly predictive of generalization and worthy of further investigation. On the other hand, several surprising failures about the norm-based measures were uncovered. In particular, we found that regularization that introduces randomness into the optimization can increase various norm of the models and spectral complexity related norm-based measures are unable to capture generalization – in fact, most of them are negatively correlated. Our experiments demonstrate that the study of generalization measure can be misleading when the number of models studied is small and the metric of quantifying the relationship is not carefully chosen. We hope this work will incentivize more rigorous treatment of generalization measures in future work.
To the best of our knowledge, this work is one of the most comprehensive study of generalization to date, but there are a few short-comings. Due to computational constraints, we were only able to study 7 most common hyperparameter types and relatively small architectures, which do not reflect the models used in production. Indeed, if more hyperparameters are considered, one could expect to better capture the causal relationship. We also only studied models trained on two image datasets (CIFAR-10 and SVHN), only classification models and only convolutional networks. We hope that future work would address these limitations.

heading: ACKNOWLEDGEMENT
text: We thank our colleagues at Google: Guy Gur-Ari for many insightful discussions that helped with the experiment design, Ethan Dyer, Pierre Foret, Sergey Ioffe for their feedback, and Scott Yak for help with implementation. We are grateful for insightful discussions with Brady Neal of University of Montreal about limitation of correlation analysis. We also thank Daniel Roy of University of Toronto for insightful comments.

heading: A NOTATION
text: We denote a probability distribution as A , set as A, tensor as A, vector as a, and scalar as a or α. Let D denote the data distributions over inputs and their labels, and let κ denote number of classes. We use , for equality by definition. We denote by S a given dataset, consisting of m i.i.d tuples {(X1, y1), . . . , (Xm, ym)} drawn from D where Xi ∈ X is the input data and yi ∈ {1, . . . , κ} the corresponding class label. We denote a feedforward neural network by fw : X → Rκ, its weight parameters by w, and the number of weights by ω , dim(w). No activation function is applied at the output (i.e. logits). Denote the weight tensor of the ith layer of the network by Wi, so that w = vec(W1, . . . ,Wd), where d is the depth of the network, and vec represents the vectorization operator. Furthermore, denote by fw(X)[j] the j-th output of the function fw(X).
Let R be the set of binary relations, and I : R → {0, 1} be the indicator function that is 1 if its input is true and zero otherwise. Let L be the 1-0 classification loss over the data distribution D : L(fw) , E(X,y)∼D [ I ( fw(X)[y] ≤ maxj 6=y fw(X)[j] )] and let L̂ be the empirical estimate of 1-0
loss over S: L̂(fw) , 1m ∑m i=1 I ( fw(X)[yi] ≤ maxj 6=yi fw(X)[j] ) . We refer to L(fw) − L̂(fw)
as the generalization gap. For any input X, we define the sample dependent margin6 as γ(X) ,( fw(X) ) [y]−maxi 6=y fw(X)i. Moreover, we define the overall margin γ as the 10th percentile (a robust surrogate for the minimum) of γ(X) over the entire training set S. Given any margin value γ ≥ 0, we define the margin loss Lγ as follows:
Lγ(fw) , E(X,y)∼D [ I ( fw(X)[y] ≤ γ + max
j 6=y fw(X)[j]
)] (6)
and L̂γ is defined in an analogous manner on the training set. Further, for any vector v, we denote by ‖v‖2 the `2 norm of v. For any tensor W, let ‖W‖F , ‖vec(W)‖. We also denote ‖W‖2 as the spectral norm of the tensor W when used with a convolution operator. For convolutional operators, we compute the true singular value with the method proposed by Sedghi et al. (2018) through FFT.
We denote a tensor as A, vector as a, and scalar as A or a. For any 1 ≤ j ≤ k, consider a k-th order tensor A and a j-th order tensor B where dimensions of B match the last j dimensions of A. We then define the product operator ⊗j :
(A⊗j B)i1,...,ik−j , 〈Ai1,...,ik−j ,B〉 , (7) where i1, . . . , ik−j are indices. We also assume that the input images have dimension n×n and there are κ classes. Given the number of input channels cin, number of output channels cout, 2D square kernel with side length k, stride s, and padding p, we define the convolutional layer convW,s,p as follows:
convW,s,p(X)i1,i2 , W⊗3patchs(i1−1)+1,s(i2−1)+1,k ( padp(X) ) ∀1 ≤ i1, i2 ≤ b n+ 2p− k s
c (8)
where W ∈ Rcout×cin×k×k is the convolutional parameter tensor, patchi,j,k(Z) is a k × k patch of Z starting from the point (i, j), and padp is the padding operator which adds p zeros to top, bottom, left and right of X:
padp(X)i1,i2,j = { Xi1,i2 p < i1, i2 ≤ n+ p 0 otherwise . (9)
We also define the max-pooling operator poolk,s,p as follows:
poolk,s,p(X)i1,i2,j = max(patchs(i1−1)+1,s(i2−1)+1 ( padp(X:,:,j) ) ) ∀1 ≤ i1, i2 ≤ b n+ 2p− k s
c (10)
6This work only concerns with the output margins, but generally margin can be defined at any layer of a deep network as introduced in (Elsayed et al., 2018) and used to establish a generalization bound in, (Wei and Ma, 2019b).
We denote by fW,s a convolutional network such that Wi ∈ Rci×ci−1×ki×ki is the convolution tensor and si is the convolutional stride at layer i. At Layer i, we assume the sequence of convolution, ReLU and max-pooling where the max pooling has kernel k′i and stride s ′ i. Lack of max-pooling in some layers can be achieved by setting k′i = s ′ i = 1. We consider classification tasks and denote the number of classes by κ.

heading: B CONDITIONAL INDEPENDENCE TEST: TOWARDS CAPTURING THE CAUSAL RELATIONSHIPS
text: Relying on correlation is intuitive but perhaps unsatisfactory. In our experiments, we change several hyper-parameters and assess the correlation between a complexity measure and generalization. When we observe correlation between a complexity measure and generalization, we want to differentiate the following two scenarios:
• Changing a hyper-parameter causes the complexity measure to be low and lower value of the measure causes the generalization gap to be low.
• Changing a hyper-parameter causes the complexity measure to be low and changing the same hyper-parameter also causes the generalization to be low but the lower value of the complexity measure by itself has no effect on generalization.
The above two scenarios are demonstrated in Figure 2-Middle and Figure 2-Right respectively. In attempt to truly understand these relationships, we will rely on the tools from probabilistic causality. Our approach is inspired by the seminal work on Inductive Causation (IC) Algorithm by Verma and Pearl (1991), which provides a framework for learning a graphical model through conditional independence test. While the IC algorithm traditionally initiates the graph to be fully connected, we will take advantage of our knowledge about generalization and prune edges of the initialized graph to expedite the computations. Namely, we assume that the choice of hyperparameter does not directly explain generalization, but rather it induces changes in some measure µ which can be used to explain generalization.
Our primary interest is to establish the existence of an edge between µ and g. Suppose there exists a large family of complexity measures and among them there is a true complexity measure that can fully explain generalization. Then to verify the existence of the edge between µ and g, we can perform the conditional independent test by reading the conditional mutual information between µ and g given that a set of hyperparameter types S is observed7. For any function φ : Θ → R, let Vφ : Θ1 × Θ2 → {+1,−1} be as Vφ(θ1, θ2) , sign(φ(θ1) − φ(θ2)). Furthermore, let US be a random variable that correspond to the values of hyperparameters in S. We calculate the conditional mutual information as follows:
I(Vµ, Vg |US) = ∑ US p(US) ∑ Vµ∈{±1} ∑ Vg∈{±1} p(Vµ, Vg |US) log ( p(Vµ, Vg |US) p(Vµ |US)p(Vg |US) ) (11)
The above removes the unwanted correlation between generalization and complexity measure that is caused by hyperparameter types in set S. Since in our case the conditional mutual information between a complexity measure and generalization is at most equal to the conditional entropy of generalization, we normalize it with the conditional entropy to arrive at a criterion ranging between 0 and 1:
H(Vg |US) = − ∑ US p(US) ∑ Vg∈{±1} p(Vg |US) log(p(Vg |US)) (12)
7For example, if S contains a single hyperparameter type such as the learning rate, then the conditional mutual information is conditioned on learning rate being observed.
Î(Vµ, Vg |US) = I(Vµ, Vg |US) H(Vg |US)
(13)
According to the IC algorithm, an edge is kept between two nodes if there exists no subset S of hyperparameter types such that the two nodes are independent, i.e. Î(Vµ, Vg |US) = 0. In our setup, setting S to the set of all hyperparameter types is not possible as both the conditional entropy and conditional mutual information would become zero. Moreover, due to computational reasons, we only look at |S| ≤ 2:
K(µ) = min US s.t |S|≤2 Î(Vµ, Vg |US) (14)
At a high level, the larger K is for a measure µ, the more likely an edge exists between µ and g, and therefore the more likely µ can explain generalization. For details on the set-up, please refer to Appendix B.1 on how these quantities are estimated.

heading: B.1 DEFINITION OF RANDOM VARIABLES
text: Since the measures are results of complicated interactions between the data, the model, and the training procedures, we cannot manipulate it to be any values that we want. Instead, we use the following definition of random variables: suppose S is a subset of all the components of θ (e.g. S = {∅} for |S| = 0, |S| = {learning rate} for |S| = 1 or |S| = {learning rate, dropout} for |S| = 2 ). Specifically we denote Sab as the collective condition {θ(a)1 = v1, θ (b) 1 = v2, . . . , θ (a) |S| = v2|S|−1, θ (b) |S| = v2|S|}. We can then define and empirical measure four probability Pr(µ (a) > µ(b), g(a) > g(b) | Sab), Pr(µ(a) > µ(b), g(a) < g(b) | Sab), Pr(µ(a) < µ(b), g(a) > g(b) | Sab) and Pr(µ(a) < µ(b), g(a) < g(b) | Sab).
Together forms a 2 by 2 table that defines the joint distribution of the Bernoulli random variables Pr(g(a) > g(b) | Sab) and Pr(µ(a) > µ(b) | Sab). For notation convenience, we use Pr(µ, g | Sab) , Pr(g | Sab) and Pr(µ | Sab) to denote the joint and marginal. If there are N = 3 choices for each hyperparameter in S then there will be N |S| such tables for each hyperparameter combination. Since each configuration occurs with equal probability, for that arbitrary θ(a) and θ(b) drawn from Θ conditioned on that the components of S are observed for both models, the joint distribution can be defined as Pr(µ, g | S) = 1
N |S| ∑ Sab Pr(µ, g | Sab) and likely the marginals can be defined as
Pr(µ | S) = 1 N |S| ∑ Sab Pr(µ | Sab) and Pr(g | S) = 1 N |S| ∑ Sab Pr(g | Sab). With these notations established, all the relevant quantities can be computed by iterating over all pairs of models.

heading: C EXPERIMENTS

heading: C.1 MORE TRAINING DETAILS
text: During our experiments, we found that Batch Normalization (Ioffe and Szegedy, 2015) is crucial to reliably reach a low cross-entropy value for all models; since normalization is a indispensable components of modern neural networks, we decide to use batch normalization in all of our models. We remove batch normalization before computing any measure by fusing the γ, β and moving statistics with the convolution operator that precedes the normalization. This is important as Dinh et al. (2017) showed that common generalization measures such as sharpness can be easily manipulated with reparameterization. We also discovered that the models trained with data augmentation often cannot fit the data (i.e. reach cross-entropy 0.01) completely. Since a model with data augmentation tends to consistently generalize better than the models without data augmentation, measure that reflects the training error (i.e. value of cross-entropy) will easily predict the ranking between two models
even though it has only learned that one model uses data augmentation (see the thought experiments from the previous section). While certain hyperparameter configuration can reach cross-entropy of 0.01 even with data augmentation, it greatly limits the space of models that we can study. Hence, we make the design choice to not include data augmentation in the models of this study. Note that from a theoretical perspective, data augmentation is also challenging to analyze since the training samples generated from the procedure are no longer identical and independently distributed. All values for all the measures we computed over these models can be found in Table 5 in Appendix C.5.

heading: C.2 THE CHOICE OF STOPPING CRITERION
text: The choice of stopping criterion is very essential and could completely change the evaluation and the resulting conclusions. In our experiments we noticed that if we pick the stopping criterion based on number of iterations or number of epochs, then since some models optimize faster than others, they end up fitting the training data more and in that case the cross-entropy itself can be very predictive of generalization. To make it harder to distinguish models based on their training performance, it makes more sense to choose the stopping criterion based on the training error or training loss. We noticed that as expected, models with the same cross-entropy usually have very similar training error so that suggests that this choice is not very important. However, during the optimization the training error behavior is noisier than cross-entropy and moreover, after the training error reaches zero, it cannot distinguish models while the cross-entropy is still meaningful after fitting the data. Therefore, we decided to use cross-entropy as the stopping criterion.

heading: C.3 ALL MODEL SPECIFICATION
text: As mentioned in the main text, the models we use resemble Network-in-Network (Gao et al., 2011) which is a class of more parameter efficient convolution neural networks that achieve reasonably competitive performance on modern image classification benchmarks. The model consists blocks of modules that have 1 3 × 3 convolution with stride 2 followed by 2 1 × 1 convolution with stride 1. We refer to this single module as a NiN-block and construct models of different size by stacking NiN-block. For simplicity, all NiN-block have the same number of output channels cout. Dropout is applied at the end of every NiN-block. At the end of the model, there is a 1×1 convolution reducing the channel number to the class number (i.e. 10 for CIFAR-10) followed by a global average pooling to produce the output logits.
For width, we choose from cout from 3 options: {2× 96, 4× 96, 8× 96}. For depth, we choose from 3 options: {2×NiNblock, 4×NiNblock, 8×NiNblock} For dropout, we choose from 3 options: {0.0, 0.25, 0.5} For batch size, we choose from: {32, 64, 128} Since each optimizer may require different learning rate and in some cases, different regularization, we fine-tuned the hyper-parameters for each optimizer while keeping 3 options for every hyperparameter choices8.
Momentum SGD: We choose momentum of 0.9 and choose the initial learning rate η from {0.1, 0.032, 0.01} and regularization coefficient λ from {0.0, 0.0001, 0.0005}. The learning rate decay schedule is ×0.1 at iterations [60000, 90000]. Adam: We choose initial learning rate η from {0.001, 3.2e−4, 1e−4}, = 1e−3 and regularization coefficient λ from {0.0, 0.0001, 0.0005}. The learning rate decay schedule is ×0.1 at iterations [60000, 90000].
RMSProp: We choose initial learning rate η from {0.001, 3.2e − 4, 1e − 4} and regularization coefficient λ from {0.0, 0.0001, 0.0003}. The learning rate decay schedule is ×0.1 at iterations [60000, 90000].
8While methods with adaptive methods generally require less tuning, in practice researchers have observed performance gains from tuning the initial learning rate and learning rate decay.

heading: C.4 CANONICAL MEASURES
text: Based on empirical observations made by the community as a whole, the canonical ordering we give to each of the hyper-parameter categories are as follows:
1. Batchsize: smaller batchsize leads to smaller generalization gap 2. Depth: deeper network leads to smaller generalization gap 3. Width: wider network leads to smaller generalization gap 4. Dropout: The higher the dropout (≤ 0.5) the smaller the generalization gap 5. Weight decay: The higher the weight decay (smaller than the maximum for each optimizer)
the smaller the generalization gap 6. Learning rate: The higher the learning rate (smaller than the maximum for each optimizer)
the smaller the generalization gap 7. Optimizer: Generalization gap of Momentum SGD<Generalization gap of Adam<Gen-
eralization gap of RMSProp

heading: C.5 ALL RESULTS
text: Below we present all of the measures we computed and their respective τ and Ψ on more than 10,000 models we trained and additional plots. Unless stated otherwise, convergence is considered when the loss reaches the value of 0.1.

heading: D COMPLEXITY MEASURES
text: In this section, we look at different complexity measures. When a measure µ is based on a generalization bound, we chose it so that the following is true with probability 0.99 (we choose the failure probability δ to be 0.01):
L ≤ L̂+ √ µ
m (15)
We also consider measures which do not provably bound the generalization error and evaluate those.
Note that in almost all cases, the canonical ordering given based on some “common" assumptions are positively correlated with the generalization in terms of both τ and Ψ; however, for optimizer, the correlation τ is close to 0. This implies that the choice of optimizer is only essentially uncorrelated with the generalization gap in the range of models we consider. This ordering helps validate many techniques used by the practioners.
D.1 VC-DIMENSION BASED MEASURES
We start by restating the theorem in (Bartlett et al., 2019) which provides an upper bound on the VC-dimension of any piece-wise linear network.
Theorem 1 (Bartlett et al. (2019)) Let F be the class of feed-forward networks with a fixed computation graph of depth d and ReLU activations. Let ai and qi be the number of activations and parameters in layer i. Then VC-dimension of F can be bounded as follows:
VC(F) ≤ d+ ( d∑ i=1 (d− i+ 1)qi ) log2 8e d∑ i=1 iai log2 4e d∑ j=1 jaj  Theorem 2 Given a convolutional network f , for any δ > 0, with probability 1 − δ over the the training set:
L ≤ L̂+ 4000
√ d log2 (6dn) 3∑d i=1 k 2 i cici−1
m +
√ log(1/δ)
m (16)
Proof We simplify the bound in Theorem 1 using a d′ to refer to the depth instead of d:
VC(F) ≤ d′ +  d′∑ i=1 (d− i+ 1)qi  log2 8e d′∑ i=1 iai log2 4e d′∑ j=1 jaj  ≤ d′ +
 d′∑ i=1 (d′ − i+ 1)qi  log2 8e d′∑ i=1 iai 2
≤ d′ + 2 log2 8e d′∑ i=1 iai  d′∑ i=1 (d′ − i+ 1)qi
≤ 3d′ log2 8e d′∑ i=1 iai  d′∑ i=1 qi
In order to extend the above bound to a convolutional network, we need to present a pooling layer with ReLU activations. First note that maximum of two inputs can be calculated using two layers with ReLU and linear activations as max(x1, x2) = x1 +ReLU(x2−x1). Now, since max-pooling at layer i has kernel sizes k′i, we need d4 log2(k′i)e layers to present that but given that the kernel size of the max-pooling layer is at most size of the image, we have
d4 log2(k′i)e ≤ d4 log2(n2)e ≤ d8 log2(n)e ≤ 9 log2(n)
Therefore, we have d′ ≤ 9d log2(n). The number of activations in any of these layers is at most n2ci since there are at most n2 pairs of neighbor pixels in an n × n image with ci channels. We ignore strides when calculating the upper bound since it only reduces number of activations at a few layers and does not change the bound significantly. Using these bounds ond′, ai and qi the equivalent network, we can bound the VC dimension as follows:
VC(F) ≤ 27d log2(n) log2 ( 8e(9d log2(n)) 2n2 ) (9 log2(n)) d∑ i=1 k2i ci−1(ci + 1)
≤ 729d log2(n)2 log2 (6dn) d∑ i=1 k2i ci−1(ci + 1)
≤ 729d log2 (6dn) 3 d∑ i=1 k2i ci−1(ci + 1)
For binary classifiers, generalization error can be in terms of Rademacher complexity (Mohri et al., 2012) which in turn can be bounded by 72 √ VC/m (Kontorovich, 2016). Therefore, we can get the following9 generalization bound:
L ≤ L̂+ 144 √ V C(F) m + √ log(1/δ) m (17)
For multi-class classification, the generalization error can be similarly bounded by Graph dimension which is an extension of VC-dimension. A simple approach get a bound on Graph dimension is to consider all pairs of classes as binary classification problem which bounds the graph dimension by κ2 V C(F). There, putting everything together, we get the following generalization bound:
L ≤ L̂+ 4000κ
√ d log2 (6dn) 3∑d i=1 k 2 i ci−1(ci + 1)
m +
√ log(1/δ)
m (18)
Inspired by Theorem 2, we define the following V C-based measure for generalization:
µV C(fw) = 4000κ √√√√d log2 (6dn)3 d∑
i=1
k2i ci−1(ci + 1) + √ log(1/δ) 2 (19) Since some of the dependencies in the above measure are probably proof artifacts, we also define another measure that is nothing but the number of parameters of the model:
µparam = d∑ i=1 k2i ci−1(ci + 1) (20)

heading: D.1.1 MEASURES ON THE OUTPUT OF THE NETWORK
text: While measures that can be calculated only based on the output of the network cannot reveal complexity of the network, they can still be very informative for predicting generalization. Therefore, we define a few measures that can be calculated solely based on the output of the network.
We start by looking at the cross-entropy over the output. Even though we used a cross-entropy based stopping criterion, the cross-entropy of the final models is not exactly the same as the stopping criterion and it could be informative. Hence we define the following measure:
µcross-entropy = 1
m m∑ i=1 `(fw(Xi), yi) (21)
where ` is the cross-entropy loss.
9The generalization gap is bounded by two times Rademacher Complexity, hence the constant 144.
Another useful and intuitive notion that appears in generalization bounds is margin. In all measures that involve margin γ, we set the margin γ to be the 10-th percentile of the margin values on the training set and therefore ensuring L̂γ ≤ 0.1. Even though margin alone is not a sensible generalization measure and can be artificially increased by scaling up the magnitude of the weights, it could still reveal information about training dynamics and therefore be informative. We report the following measure based on the margin:
µ1/margin(fw) = 1
γ2 (22)
Finally, entropy of the output is another interesting measure and it has been shown that regularizing it can improve generalization in deep learning (Pereyra et al., 2017). With a fixed cross-entropy, increasing the entropy corresponds to distribute the uncertainty of the predictions equally among the wrong labels which is connected to label smoothing and increasing the margin. We define the following measure which is the negative entropy of the output of the network:
µneg-entropy(fw) = 1
m m∑ i=1 κ∑ j=1 pi[j] log(pi[j]) (23)
where pi[j] is the predicted probability of the class j for the input data Xi.

heading: D.2 (NORM & MARGIN)-BASED MEASURES
text: Several generalization bounds have been proved for neural networks using margin and norm notions. In this section, we go over several such measures. For fully connected networks, Bartlett and Mendelson (2002) have shown a bound based on product of `1,∞ norm of the layer weights times a 2d factor where `1,∞ is the maximum over hidden units of the `2 norm of the incoming weights to the hidden unit. Neyshabur et al. (2015b) proved a bound based on product of Frobenius norms of the layer weights times a 2d factor and Golowich et al. (2017) was able to improve the factor to √ d. Bartlett et al. (2017) proved a bound based on product of spectral norm of the layer weights times sum over layers of ratio of Frobenius norm to spectral norm of the layer weights and Neyshabur et al. (2018a) showed a similar bound can be achieved in a simpler way using PAC-bayesian framework.
Spectral Norm Unfortunately, none of the above founds are directly applicable to convolutional networks. Pitas et al. (2017) built on Neyshabur et al. (2018a) and extended the bound on the spectral norm to convolutional networks. The bound is very similar to the one for fully connected networks by Bartlett et al. (2017). We next restate their generalization bound for convolutional networks including the constants.
Theorem 3 (Pitas et al. (2017)) Let B an upper bound on the `2 norm of any point in the input domain. For any B, γ, δ > 0, the following bound holds with probability 1− δ over the training set:
L ≤ L̂γ + √√√√(84B∑di=1 ki√ci +√ln(4n2d))2∏di=1 ‖Wi‖22∑dj=1 ‖Wj−W0j‖2F‖Wj‖22 + ln(mδ ) γ2m
(24)
Inspired by the above theorem, we define the following spectral measure:
µspec,init(fw) =
( 84B ∑d i=1 ki √ ci + √ ln(4n2d) )2∏d i=1 ‖Wi‖ 2 2 ∑d j=1 ‖Wj−W0j‖2F ‖Wj‖22 + ln(mδ )
γ2
(25) The generalization bound in Theorem 3 depends on reference tensors W0i . We chose the initial tensor as the reference in the above measure but another reasonable choice is the origin which gives the following measures:
µspec-orig(fw) =
( 84B ∑d i=1 ki √ ci + √ ln(4n2d) )2∏d i=1 ‖Wi‖ 2 2 ∑d j=1
‖Wj‖2F ‖Wj‖22 + ln(mδ )
γ2 (26)
Since some of the terms in the generalization bounds might be proof artifacts, we also measure the main terms in the generalization bound:
µspec-init-main(fw) =
∏d i=1 ‖Wi‖ 2 2 ∑d j=1 ‖Wj−W0j‖2F ‖Wj‖22
γ2 (27)
µspec-orig-main(fw) =
∏d i=1 ‖Wi‖ 2 2 ∑d j=1
‖Wj‖2F ‖Wj‖22
γ2 (28)
We further look at the main two terms in the bound separately to be able to differentiate their contributions.
µspec-init-main(fw) =
∏d i=1 ‖Wi‖ 2 2 ∑d j=1 ‖Wj−W0j‖2F ‖Wj‖22
γ2 (29)
µspec-orig-main(fw) =
∏d i=1 ‖Wi‖ 2 2 ∑d j=1
‖Wj‖2F ‖Wj‖22
γ2 (30)
µprod-of-spec/margin(fw) =
∏d i=1 ‖Wi‖ 2 2
γ2 (31)
µprod-of-spec(fw) = d∏ i=1 ‖Wi‖22 (32)
µfro/spec(fw) = d∑ i=1 ‖Wi‖2F ‖Wi‖22
(33)
Finally, since product of spectral norms almost certainly increases with depth, we look at the following measure which is equal to the sum over squared spectral norms after rebalancing the layers to have the same spectral norms:
µsum-of-spec/margin(fw) = d
(∏d i=1 ‖Wi‖ 2 2
γ2
)1/d (34)
µsum-of-spec(fw) = d ( ‖Wi‖22 )1/d (35)
Frobenius Norm The generalization bound given in Neyshabur et al. (2015b) is not directly applicable to convolutional networks. However, Since for each layer i, we have ‖Wi‖2 ≤ k2i ‖Wi‖F and therefore by Theorem 3, we can get an upper bound on the test error based on product of Frobenius norms. Therefore, we define the following measure based on the product of Frobenius norms:
µprod-of-fro/margin(fw) =
∏d i=1 ‖Wi‖ 2 F
γ2 (36)
µprod-of-fro(fw) = d∏ i=1 ‖Wi‖2F (37)
We also look at the following measure with correspond to sum of squared Frobenius norms of the layers after rebalancing them to have the same norm:
µsum-of-fro/margin(fw) = d
(∏d i=1 ‖Wi‖ 2 F
γ2
)1/d (38)
µsum-of-fro(fw) = d ( d∏ i=1 ‖Wi‖2F )1/d (39)
Finally, given recent evidence on the importance of distance to initialization (Dziugaite and Roy, 2017; Nagarajan and Kolter, 2019b; Neyshabur et al., 2018b), we calculate the following measures:
µfrobenius-distance (fw) = d∑ i=1 ∥∥Wi −W0i ∥∥2F (40) µdist-spec-init(fw) =
d∑ i=1 ∥∥Wi −W0i ∥∥22 (41) In case when the reference matrix W0i = 0 for all weights, Eq (40) the Frobenius norm of the parameters which also correspond to distance from the origin:
µparam-norm(fw) = d∑ i=1 ‖Wi‖2F (42)
Path-norm Path-norm was introduced in Neyshabur et al. (2015b) as an scale invariant complexity measure for generalization and is shown to be a useful geometry for optimization Neyshabur et al. (2015a). To calculate path-norm, we square the parameters of the network, do a forward pass on an all-ones input and then take square root of sum of the network outputs. We define the following measures based on the path-norm:
µpath-norm/margin(fw) =
∑ i fw2(1)[i]
γ2 (43) µpath-norm(fw) = ∑ i fw2(1) (44)
where w2 = w ◦w is the element-wise square operation on the parameters.
Fisher-Rao Norm Fisher-Rao metric was introduced in Liang et al. (2017) as a complexity measure for neural networks. Liang et al. (2017) showed that Fisher-Rao norm is a lower bound on the path-norm and it correlates in some cases. We define a measure based on the Fisher-Rao matric of the network:
µFisher-Rao(fw) = (d+ 1)2
m
m∑ i=1 〈w,∇w`(fw(Xi)), yi〉2 (45)
where ` is the cross-entropy loss.

heading: D.3 FLATNESS-BASED MEASURES
text: PAC-Bayesian framework (McAllester, 1999) allows us to study flatness of a solution and connect it to generalization. Given a prior P is is chosen before observing the training set and a posterior Q which is a distribution on the solutions of the learning algorithm (and hence depends on the training set), we can bound the expected generalization error of solutions generated from Q with high probability based on the KL divergence of P and Q. The next theorem states a simplified version of PAC-Bayesian bounds.
Theorem 4 For any δ > 0, distribution D, prior P , with probability 1− δ over the training set, for any posterior Q the following bound holds:
Ev∼Q [L(fv)] ≤ Ew∼Q [ L̂(fv) ] +
√ KL(Q||P ) + log ( m δ ) 2(m− 1)
(46)
If P and Q are Gaussian distributions with P = N (µP ,ΣP ) amd Q = N (µQ,ΣQ), then the KL-term can be written as follows:
KL(N (µQ,ΣQ)||N (µP ,ΣP )) = 1
2
[ tr ( Σ−1P ΣQ ) + (µQ − µP )>Σ−1P (µQ − µP )− k + ln(
det ΣP det ΣQ )
] .
SettingQ = N (w, σ2I) andP = N (w0, σ2I) similar to Neyshabur et al. (2017), the KL term will be simply ‖w−w0‖2 2
2σ2 . However, since σ belongs to prior, if we search to find a value for σ, we need to adjust the bound to reflect that. Since we search over less than 20000 predefined values of σ in our experiments, we can use the union bound which changes the logarithmic term to log(20000m/δ) and we get the following bound:
Eu∼N (u,σ2I) [L(fw+u)] ≤ Eu∼N (u,σ2I) [ L̂(fw+u) ] +
√ ‖w−w0‖22
4σ2 + log( m σ ) + 10
m− 1 (47)
Based on the above bound, we define the following measures using the origin and initialization as reference tensors:
µpac-bayes-init(fw) =
∥∥w −w0∥∥2 2
4σ2 + log(
m σ ) + 10 (48)
µpac-bayes-orig(fw) = ‖w‖22 4σ2 + log( m δ ) + 10 (49)
where σ is chosen to be the largest number such that Eu∼N (u,σ2I) [ L̂(fw+u) ] ≤ 0.1.
The above framework captures flatness in the expected sense since we add Gaussian perturbations to the parameters. Another notion of flatness is the worst-case flatness where we search for the direction that changes the loss the most. This is motivated by (Keskar et al., 2016) where they observe that this notion would correlate to generalization in the case of different batch sizes. We can use PAC-Bayesian framework to give generalization bounds for worst-case perturbations as well. The magnitude of a Gaussian variable with with variance σ2 is at most σ √ 2 log(2/δ) with probability 1− δ/2. Applying a union bound on all parameters, we get that with probability 1− δ/2 the magnitude of the Gaussian noise is at most α = σ √ 2 log(2ω/δ) where ω is the number of parameters of the model. Therefore, we can get the following generalization bound:
Eu∼N (u,σ2I) [L(fw+u)] ≤ max |ui|≤α L̂(fw+u) +
√ ‖w−w0‖22 log(2ω/δ)
2α2 + log( 2m δ ) + 10
m− 1 (50)
Inspired by the above bound, we define the following measures:
µsharpness-init(fw) =
∥∥w −w0∥∥2 2 log(2ω)
4α2 + log(
m σ ) + 10 (51)
µsharpness-orig(fw) = ‖w‖22 log(2ω)
4α2 + log(
m δ ) + 10 (52)
where α is chosen to be the largest number such that max|ui|≤α L̂(fw+u) ≤ 0.1. To understand the importance of the flatness parameters σ and α, we also define the following measures:
µpac-bayes-flatness(fw) = 1
σ2 (53)
µsharpness-flatness(fw) = 1
α2 (54)
where α and σ are computed as explained above.
Magnitude-aware Perturbation Bounds The magnitude of perturbation in (Keskar et al., 2016) was chosen so that for each parameter the ratio of magnitude of perturbation to the magnitude of the parameter is bounded by a constant α′10. Following a similar approach, we can choose the posterior for parameter i in PAC-Bayesian framework to be N (wi, σ′2|wi|2 + 2). Now, substituting this
10They actually used a slightly different version which is a combination of the two perturbation bounds we calculated here. Here, for more clarity, we decomposed it into two separate perturbation bounds.
in the Equation equation D.3 and solving for the prior N (w0, σ2P ) that minimizes the KL term by setting the gradient with respect to σP2 to zero, KL can be written as follows:
2KL(Q||P ) = ω log ( σ′2 + 1
ω
∥∥w −w0∥∥2 2 + 2 ) − ω∑ i=1 log ( σ′2|wi − w0i |2 + 2 ) =
ω∑ i=1 log
( 2 + (σ′2 + 1) ∥∥w −w0∥∥2 2 /ω
2 + σ′2|wi − w0i |2 ) Therefore, the generalization bound can be written as follows
Eu [L(fw+u)] ≤ Eu [ L̂(fw+u) ] + √√√√ 14 ∑ωi=1 log ( 2+(σ′2+1)‖w−w0‖22/ω 2+σ′2|wi−w0i |2 )+ log(mδ ) + 10 m− 1 (55) where ui ∼ N (0, σ′2|wi| + 2), = 1e − 3 and σ′ is chosen to be the largest number such that Eu [ L̂(fw+u) ] ≤ 0.1. We define the following measures based on the generalization bound:
µpac-bayes-mag-init(fw) = 1
4 ω∑ i=1 log
( 2 + (σ′2 + 1) ∥∥w −w0∥∥2 2 /ω
2 + σ′2|wi − w0i |2
) + log( m
δ ) + 10 (56)
µpac-bayes-mag-orig(fw) = 1
4 ω∑ i=1 log ( 2 + (σ′2 + 1) ‖w‖22 /ω 2 + σ′2|wi − w0i |2 ) + log( m δ ) + 10 (57)
We also follow similar arguments are before to get a similar bound on the worst-case sharpness:
Eu [L(fw+u)] ≤ max |ui|≤α′|wi|+ L̂(fw+u)+ √√√√ 14 ∑ωi=1 log ( 2+(α′2+4 log(2ω/δ))‖w−w0‖22/ω 2+α′2|wi−w0i |2 )+ log(mδ ) + 10 m− 1 (58) We look at the following measures based on the above bound:
µpac-sharpness-mag-init(fw) = 1
4 ω∑ i=1 log
( 2 + (α′2 + 4 log(2ω/δ)) ∥∥w −w0∥∥2 2 /ω
2 + α′2|wi − w0i |2
) + log( m
δ ) + 10
(59)
µpac-sharpness-mag-orig(fw) = 1
4 ω∑ i=1 log
( 2 + (α′2 + 4 log(2ω/δ)) ‖w‖22 /ω
2 + α′2|wi − w0i |2
) + log( m
δ ) + 10
(60)
Finally, we look at measures that are only based the sharpness values computed above:
µpac-bayes-mag-flat(fw) = 1
σ′2 (61)
µsharpness-mag-flat(fw) = 1
α′2 (62)
where α and σ are computed as explained above.

heading: D.4 OPTIMIZATION-BASED MEASURES
text: There are mixed results about how the optimization speed is relevant to generalization. On one hand we know that adding Batch Normalization or using shortcuts in residual architectures help both optimization and generalization and Hardt et al. (2015) suggests that faster optimization results in better generalization. On the other hand, there are empirical results showing that adaptive optimization methods that are faster, usually generalize worse (Wilson et al., 2017b). Here, we put these hypothesis into test by looking at the number of steps to achieve cross-entropy 0.1 and the number of steps needed to go from cross-entropy 0.1 to 0.01:
µ#steps-0.1-loss(fw) = #steps from initialization to 0.1 cross-entropy (63) µ#steps-0.1-0.01-loss(fw) = #steps from 0.1 to 0.01 cross-entropy (64)
The above measures tell us if the speed of optimization at early or late stages can be informative about generalization. We also define measures that look at the SGD gradient noise after the first epoch and at the end of training at cross-entropy 0.01 to test the gradient noise can be predictive of generalization:
µgrad-noise-epoch1(fw) = Var(X,y) S (∇w`(fw1(X), y)) (65) µgrad-noise-final(fw) = Var(X,y) S (∇w`(fw(X), y)) (66)
where w1 is the weight vector after the first epoch.

heading: E ALGORITHMS
text: We first lay out some common notations used in the pseudocode:
1. f : the architecture that takes parameter θ and input x and map to f(x; θ) which is the predicted label of x
2. θ: parameters 3. M : Some kind of iteration; M1: binary search depth; M2: Monte Carlo Estimation steps; M3: Iteration for estimating the loss
4. D = {(xi, yi)}ni=0 the dataset the model is trained on; B as a uniformly sampled minibatch from the dataset.
Both search algorithm relies on the assumption that the loss increases monotonically with the perturbation magnitude σ around the final weight. This assumption is quite mild and in reality holds across almost all the models in this study.
Algorithm 1 EstimateAccuracy 1: Inputs: model f , parameter θ, dataset D , estimate iteration M 2: Initialize Accuracy = 0 3: for episode i = 1 to M do 4: B ∼ sample(D) 5: Accuracy += 1|B| ∑ i δ(yi = f(Bi; θ))
6: end for 7: return Accuracy/M
Note that for finding the sharpness σ, we use the cross-entropy as the differentiable surrogate object instead of the 1-0 loss which is in general not differentiable. Using gradient ascent brings another additional challenge that is for a converged model, the local gradient signal is usually weak, making gradient ascent extremely inefficient. To speed up thie process, we add a uniform noise with range being [−σnew/Nw, σnew/Nw] to lift the weight off the flat minima where Nw is the number of parameters. This empirical greatly accelerates the search.
Further, for magnitude aware version of the bounds, the overall algorithm stays the same with the exception that now covariance matrices at line 7 of Algorithm 2 become as diagonal matrix containing w2i on the diagonal; similarly, for line 12 of Algorithm 3, the weight clipping of each wi is conditioned on σnew|wi|, i.e. clipped to [−σnew|wi|, σnew|wi|]. Here wi denotes the ith parameter of flattened w.
Algorithm 2 Find σ for PAC-Bayesian Bound 1: Inputs: f , θ0, model accuracy `, target accuracy deviation d, Upper bound σmax, Lower bound σmin, M1, M2, M3
2: Initialize 3: for episode i = 1 to M1 do 4: σnew = (σmax + σmin)/2 5: ˆ̀= 0 6: for step j = 0 to M2 do 7: θ ← θ0 +N (0, σ2newI) 8: ˆ̀= ˆ̀+ EstimateAccuracy(f, θnew,D ,M3) 9: end for
10: ˆ̀= ˆ̀/M2 11: d̂ = |`− ˆ̀| 12: if d̂ < d or σmax − σmin < σ then 13: return σnew 14: end if 15: if d̂ > d then 16: σmax = σnew 17: else 18: σmin = σnew 19: end if 20: end for
Algorithm 3 Find σ for Sharpness Bound 1: Inputs: f , θ0, loss function L, model accuracy `, target accuracy deviation d, Upper bound σmax, Lower bound σmin, M1, M2, M3, gradient steps M4
2: Initialize 3: for episode i = 1 to M1 do 4: σnew = (σmax + σmin)/2 5: ˆ̀=∞ 6: for step j = 0 to M2 do 7: θ = θ0 + U(σnew/2) 8: for step k = 0 to M4 do 9: B ∼ sample(D)
10: θ = θ + η∇θ`(f,B, θ) 11: if ||θ|| > σnew then 12: θ = σnew · θ||θ|| 13: end if 14: end for 15: ˆ̀= min(ˆ̀,EstimateAccuracy(f, θnew,D ,M3)) 16: end for 17: d̂ = |`− ˆ̀| 18: if d̂ < d or σmax − σmin < σ then 19: return σnew 20: end if 21: if d̂ > d then 22: σmax = σnew 23: else 24: σmin = σnew 25: end if 26: end for

Review summaries:
The paper addresses the well-known generalization problem for deep networks: why do these models successfully generalize even though they contain more parameters than the size of the training set? Recent works on this problem have proposed various measures of model complexity (that is, different from the number of parameters) with the claim that they (at least partially) capture the "true" capacity of deep networks in order to answer this question. The authors report the results of a large-scale, systematic study of the empirical effect of these complexity measures on the observed generalization behavior of deep networks.