Identifying Generalization Properties in Neural Networks

Huan Wang, Nitish Shirish Keskar, Caiming Xiong, Richard Socher

Introduction

Deep models have proven to work well in applications such as computer vision (Krizhevsky et al., 2012) (He et al., 2014) (Karpathy et al., 2014), speech recognition (Mohamed et al., 2012) (Hinton et al., 2012), and natural language processing (Socher et al., 2013) (Graves, 2013) (McCann et al., 2018). Many deep models have millions of parameters, which is more than the number of training samples, but the models still generalize well (Huang et al., 2017).

On the other hand, classical learning theory suggests the model generalization capability is closely related to the “complexity” of the hypothesis space. This seems to be a contradiction to the empirical observations that over-parameterized models generalize well on the test data. Indeed, even if the hypothesis space is complex, the final solution learned from a given training set may still be simple. An example is, suppose the hypothesis space is the union of linear classifiers and some complex function spaces. As a union set the hypothesis space is complex in the worst case, but for some training set the best solution may be a linear classifier. This suggests the generalization capability of the model is also related to the property of the solution.

Keskar et al. (2016) and Chaudhari et al. (2016) empirically observe that the generalization ability of a model is related to the spectrum of the Hessian matrix ∇2L(w∗)\nabla^{2}L(w^{\ast}) evaluated at the solution, and large eigenvalues of the ∇2L(w∗)\nabla^{2}L(w^{\ast}) often leads to poor model generalization. Also, (Keskar et al., 2016), (Chaudhari et al., 2016) and (Novak et al., 2018b) introduce several different metrics to measure the “sharpness” of the solution, and demonstrate the connection between the sharpness metric and the generalization empirically. Dinh et al. (2017) later points out that most of the Hessian-based sharpness measures are problematic and cannot be applied directly to explain generalization. In particular, they show that the geometry of the parameters in RELU-MLP can be modified drastically by re-parameterization.

Another line of work originates from the theorists. (Langford and Caruana, 2001) and more recently (Harvey et al., 2017) (Neyshabur et al., 2017a) (Neyshabur et al., 2017b) use PAC-Bayes bound to analysis the generalization behavior of the deep models. Since the PAC-Bayes bound holds uniformly for all “posteriors”, it also holds for some particular “posteriors”, for example, the solution parameter perturbed with noise. This provides a natural way to incorporate the local property of the solution into the generalization analysis. In particular, Neyshabur et al. (2017a) suggests to use the difference between the perturbed loss and the empirical loss as the sharpness metric. Dziugaite and Roy (2017) tries to optimize the PAC-Bayes bound instead for a better model generalization. Still some fundamental questions remain unanswered. In particular we are interested in the following question:

How is model generalization related to local “smoothness” of a solution?

In this paper we try to answer the question from the PAC-Bayes perspective. Under mild assumptions on the Hessian of the loss function, we prove the generalization error of the model is related to this Hessian, the Lipschitz constant of the Hessian, the scales of the parameters, as well as the number of training samples. The analysis also gives rise to a new metric for generalization. Based on this, we can approximately select an optimal perturbation level to aid generalization which interestingly turns out to be related to Hessian as well. Inspired by this observation, we propose a perturbation based algorithm that makes use of the estimation of the Hessian to improve model generalization.

Sharp Minimum v.s. Flat Minimum - A Toy Example

Let us start with a toy example to demonstrate different behaviors of local optima. For training, we construct a small 2-dimensional sample set from a mixture of 33 Gaussians, and then binarize the labels by thresholding them from their median value. The sample distribution is shown in Figure 1(b). Then we use a 55-layer MLP model with sigmoid as the activation and cross entropy as the loss for training and prediction. The variables from different layers are shared so that the model only has two free parameters w1w_{1} and w2w_{2}.

The model is trained using 100100 samples. Fixing the samples, we plot the loss function with respect to the model variables L^(w1,w2)\hat{L}(w_{1},w_{2}), as shown in Figure 1(a). Many local optima are observed even in this simple two-dimensional toy example. In particular a sharp one, marked by the vertical green line, and a flat one, marked by the vertical red line. The colors on the loss surface display the values of the generalization metric scores (pacGen), which we will define in section 7. Smaller metric value indicates better generalization power.

As displayed in the figure, the metric score around the global optimum, indicated by the vertical green bar, is high, suggesting possible poor generalization capability as compared to the local optimum indicated by the red bar. We also plot a plane on the bottom of the figure. The color projected on the bottom plane indicates an approximated generalization bound, which considers both the loss and the generalization metric.the bound was approximated with η=39\eta=39 using inequality (13) The local optimum indicated by the red bar, though has a slightly higher loss, has a similar overall bound compared to the “sharp” global optimum.

On the other hand, fixing the parameter w1w_{1} and w2w_{2}, we may also plot the labels predicted by the model given the samples. Here we plot the prediction from both the sharp minimum (Figure 1(c)) and the flat minimum (Figure 1(d)). The sharp minimum, even though it approximates the true label better, has some complex structures in its predicted labels, while the flat minimum seems to produce a simpler classification boundary.

While it is easy to make observations on toy examples, it is less straight-forward to make a quantitative statement when the model parameters and the number of training samples grow. In the following sections we try connect the local smoothness of the solution and model generalization capability. Section 3 briefly introduces some preliminaries on the learning theory. Section 4 talks about the assumptions and intuitions on how the model perturbation is related to the generalization as well as the Hessian of the solution. Section 5 dives into two specific types of perturbations: uniform and truncated Gaussian. Section 6 discusses the effect of re-parameterization on the proposed bound. Some empirical approximations and experiments are shown in Section 7 and 8.

Model Generalization Theory

Since we do not know the distribution Ds\mathfrak{D}_{s}, the expected loss L(f)L(f) is hard to calculate directly. Instead usually the empirical loss

is evaluated during the training procedure.

may lead to issues such as overfitting. In general, by the law of large number, for a fixed function f∈Ff\in\mathfrak{F}, the empirical loss converges almost surely to the expected loss. However, when ff is not fixed, i.e., ff depends on the samples, and the number of samples is finite, classical learning theory suggests that the gap between the expected loss and the empirical loss is bounded by the sum of the Rademacher complexity and a concentration tail (Shalev-Shwartz and Ben-David, 2014). The Rademacher complexity is defined as

where ϵi\epsilon_{i}s are i.i.d. Rademacher random variables.

Note the Rademacher complexity is only related to the function space F\mathfrak{F}, the sample distribution Ds\mathfrak{D}_{s} and the number of samples nn. This seems to suggest when the function class is very complex, the gap between the empirical loss and the expected loss will be large. Though the learning theory based on Rademacher complexity can explain the overfitting effect to some extent, for example, when the hypothesis space is overly complex, the generalization tends to be worse, it is not easy to explain some well-known empirical observations in today’s deep learning experiments including:

The hypothesis space of a deep learning network can easily get rich enough to represent any function on a finite sample set (Zhang et al., 2017). According to the bound based on the Rademacher complexity, the network may tend to overfit. However empirically those deep models generalize well.

Different generalization behaviors for different local optima.

The generalization bound based on Rademacher complexity holds uniformly for all hypothesis in the function class. On the other hand, it does not distinguish the generalization capabilities among different solutions. Obviously, there are “simple” solutions even if the whole function space is complex.

In this draft we will focus on the second empirical observations and give, to the best of our knowledge, a first explanation on behaviors of different local optima.

2 PAC-Bayes

Another line of theory discussing model generalization is PAC-Bayes (Mcallester, 2003) (McAllester, 1998) (McAllester, 1999) (Langford and Shawe-Taylor, 2002). The PAC-Bayes paradigm further assumes probability measures over the function class. In particular, it assumes a “posterior” distribution Df\mathfrak{D}_{f} as well as a “prior” distribution πf\pi_{f} over the function class F\mathfrak{F}. In this way the function is assumed to be sampled from a “posterior” distribution over F\mathfrak{F}. As a consequence the expected loss is in terms of both the random draw of samples as well as the random draw of functions:

Correspondingly, the empirical loss in the PAC-Bayes paradigm is the expected loss over the draw of functions from the posterior:

PAC-Bayes theory suggests the gap between the expected loss and the empirical loss is bounded by a term that is related to the KL divergence between Df\mathfrak{D}_{f} and πf\pi_{f} (McAllester, 1999) (Langford and Shawe-Taylor, 2002). In particular, if the function ff is parameterized as f(w)f(w) with w∈Ww\in\mathcal{W}, when Dw\mathfrak{D}_{w} is perturbed around any ww, we have the following PAC-Bayes bound (Seldin et al., 2012) (Seldin et al., 2011) (Neyshabur et al., 2017a) (Neyshabur et al., 2017b):

Let l(f,x,y)∈l(f,x,y)\in, and π\pi be any fixed distribution over the parameters W\mathcal{W}. For any δ>0\delta>0 and η>0\eta>0, with probability at least 1−δ1-\delta over the draw of nn samples, for any ww and any random perturbation uu,

Local Smoothness Assumptions

Keskar et al. (2016) investigate the local structures of the converged points for deep learning networks, and find that empirically the “sharpness” of the minima is closely related to the generalization property of the classifier. The sharp minimizers, which led to lack of generalization ability, are characterized by a significant number of large positive eigenvalues in ∇2f(x)\nabla^{2}f(x). In particular, they propose a local sharpness metric:

Other variants of the model generalization metrics are also proposed by Chaudhari et al. (2016) and Novak et al. (2018b).

Neyshabur et al. (2017a) suggests an “expected sharpness” based on the PAC-Bayes bound:

They also point out the sharpness itself may not be enough to determine the generalization capability, but combining scales with sharpness one may get a control of the generalization. Similar connections are also found by Dziugaite and Roy (2017).

While some researchers have discovered empirically the generalization ability of the models is related to the second order information around the local optima, to the best of our knowledge there is no work on how to connect the Hessian matrix ∇2L^(w)\nabla^{2}\hat{L}(w) with the model generalization. In this section we introduce the assumption about the second-order smoothness, which is later used in our generalization bound.

A twice differentiable function f(⋅)f(\cdot) is ρ\rho-Hessian Lipschitz if:

The Hessian Lipschitz condition has been used in the numeric optimization community to model the second-order smoothness (Nesterov and Polyak, 2006) (Allen-Zhu and Orecchia, 2014). For the deep models it could be unrealistic to assume the Hessian Lipschitz condition holds for all w∈Ww\in\mathcal{W}. Instead we make a local Hessian Lipschitz assumption:

Function L^(w)\hat{L}(w) is ρ\rho-Hessian Lipschitz in Neighγ,ϵ(w)Neigh_{\gamma,\epsilon}(w), where

is a neighborhood around ww defined by two positive constants γ\gamma and ϵ\epsilon.

To simplify the notation in the draft we denote κγ,ϵ(wi)=γ∣wi∣+ϵ\kappa_{\gamma,\epsilon}(w_{i})=\gamma|w_{i}|+\epsilon.

2 Connecting Generalization and Hessian

Suppose the empirical loss function L^(w)\hat{L}(w) satisfies the local Hessian Lipschitz condition, then by Lemma 11 in (Nesterov and Polyak, 2006), the perturbation of the function around a fixed point can be bounded by terms up to the third-order,

where ∇i2\nabla^{2}_{i} is simply the ii-th diagonal element in Hessian. The following lemma is straight-forward given (1),(5), and (6).

where ∇i\nabla_{i} is the ii-th diagonal element of ∇L^(w)\nabla\hat{L}(w).

Note by extrema of the Rayleigh quotient, the quadratic term on the right hand side of inequality (5) is further bounded by

This is consistent with the empirical observations of Keskar et al. (2016) that the generalization ability of the model is related to the eigenvalues of ∇2L^(w)\nabla^{2}\hat{L}(w). The inequality (8) still holds even if the perturbations uiu_{i} and uju_{j} are correlated. We add another lemma about correlated perturbations in Appendix (Lemma 9).

3 Tradeoff between Sharpness Metric and Generalization Power

If we look at the right hand side of the inequality (7), and compare it with (3) (Neyshabur et al., 2017a), we see

is related to the model generalization power in the original PAC-Bayes bound.

Ideally we would like both M(w,Du)\mathcal{M}(w,\mathcal{D}_{u}) and Gδ,n(η,Dw+u,π)\mathcal{G}_{\delta,n}(\eta,\mathcal{D}_{w+u},\pi) to be small for better generalization capability. However, generally the perturbation distribution that leads to small M(w,Du)\mathcal{M}(w,\mathcal{D}_{u}) tends to have large Gδ,n(η,Dw+u,π)\mathcal{G}_{\delta,n}(\eta,\mathcal{D}_{w+u},\pi) for a given prior. As we will see in the following sections, in the end we have to make trade-offs between the two terms.

Bounded Perturbations

Adding noise to the model for better generalization has proven successful both empirically and theoretically (Zhu et al., 2018) (Hoffer et al., 2017) (Jastrzȩbski et al., 2017) (Dziugaite and Roy, 2017) (Novak et al., 2018a). Instead of only minimizing the empirical loss, (Langford and Caruana, 2001) and (Dziugaite and Roy, 2017) assume different perturbation levels on different parameters, and minimize the generalization bound led by PAC-Bayes for better model generalization. However how to connect the noise distribution with the local optima structures, for example, ∇2L(w∗)\nabla^{2}L(w^{\ast}), and how that is related to the generalization power have not been examined.

Since the assumptions in Lemma (5) are local, the distributions of interest for the perturbation are necessarily bounded. In this section we investigate two special forms of perturbations, the uniform perturbation and truncated Gaussian, and provide closed-form scale estimation for the perturbation levels.

Suppose ui∼U(−σi,σi)u_{i}\sim U(-\sigma_{i},\sigma_{i}), and σi≤κγ,ϵ(wi)  ∀i\sigma_{i}\leq\kappa_{\gamma,\epsilon}(w_{i})~{}~{}\forall i. That is, the “posterior” distribution of the model parameters are uniform distribution, and the distribution supports vary for different parameters. We also assume the perturbed parameters are bounded, i.e., ∣wi∣+κγ,ϵ(wi)≤τi  ∀i|w_{i}|+\kappa_{\gamma,\epsilon}(w_{i})\leq\tau_{i}~{}~{}\forall i.One may also assume the same τ\tau for all parameters for a simpler argument. The proof procedure goes through in a similar way. If we choose the priors π\pi to be ui∼U(−τi,τi)u_{i}\sim U(-\tau_{i},\tau_{i}), and then

Note E[ui2]=σi2/3E[u_{i}^{2}]=\sigma_{i}^{2}/3. Also we simplify the third order term in (7) by

where we use the inequality ∥u∥2≤m16∥u∥3\|u\|_{2}\leq m^{\frac{1}{6}}\|u\|_{3} and mm is the number of parameters. By Lemma (5), we get

If we assume L^(w)\hat{L}(w) is locally convex around w∗w^{\ast} so that ∇i2L^(w∗)≥0\nabla^{2}_{i}\hat{L}(w^{\ast})\geq 0 for all ii. Solve for σ\sigma that minimizes the right hand side, and we have the following lemma:

where ui∼U(−σi∗,σi∗)u_{i}\sim U(-\sigma_{i}^{\ast},\sigma_{i}^{\ast}) are i.i.d. uniformly perturbed random variables, and

In our experiment, we simply treat η\eta as a hyper-parameter. Other other hand, one may further build a weighted grid over η\eta and optimize for the best η\eta (Seldin et al., 2011). In this way we reach the following theorem:

where ui∼U(−σi∗,σi∗)u_{i}\sim U(-\sigma_{i}^{\ast},\sigma_{i}^{\ast}) are i.i.d. uniformly perturbed random variables, and

Please see the appendix for the details of the proof.

2 Truncated Gaussian

Because the Gaussian distribution is not bounded but Lemma (5) requires bounded perturbation, we first truncate the distribution. The procedure of truncation is similar to the proof in (Neyshabur et al., 2017b) and (Mcallester, 2003).

Suppose the coefficients are bounded such that ∑iwi2≤τ\sum_{i}w_{i}^{2}\leq\tau, where τ\tau is a constant. Choose the prior π\pi as N(0,τI)N(0,\tau I), and we have

Notice that after the truncation the variance only becomes smaller, so the bound of (7) for the truncated Gaussian becomes

Again when L^(w)\hat{L}(w) is convex around w∗w^{\ast} such that ∇2L^(w∗)≥0\nabla^{2}\hat{L}(w^{\ast})\geq 0, solve for the best σi\sigma_{i} and we get the following lemma:

and σi∗2\sigma_{i}^{\ast 2} is the ii-th diagonal element in Σ∗\Sigma^{\ast}.

Again We have an extra term η\eta, which may be further optimized over a grid to get a tighter bound. In our algorithm we treat η\eta as a hyper-parameter instead.

On the Re-parameterization of RELU-MLP

Dinh et al. (2017) points out the spectrum of ∇2L^\nabla^{2}\hat{L} itself is not enough to determine the generalization power. One particular example is the multiple layer perceptron with RELU as the activations (RELU-MLP). For a two-layer RELU-MLP, denote w1w^{1}, and w2w^{2} as the linear coefficients for the first and second layer. Clearly

If cross entropy (negative log likelihood) is used as the loss function, under certain regularization conditions, if p(x,y)=f(x,w∗)[y]p(x,y)=f(x,w^{\ast})[y], i.e., w∗w^{\ast} is the “true” parameter of the sample distribution, the change in Hessian to re-parameterization can be calculated as the outer product of the gradients, in this case

In general our bound does not assume the loss function to be cross entropy loss. Also we do not assume the model is RELU-MLP. As a result we would not expect our bound stays exactly the same during the re-parameterization.

On the other hand, the optimal perturbation levels in our bound scales inversely during the scaling of parameters, so the bound only changes approximately with a speed of logarithmic factor. According to Lemma (6) and (8), if we use the optimal σ∗\sigma^{\ast} on the right hand side of the bound, ∇2L^(w)\nabla^{2}\hat{L}(w), ρ\rho, and w∗w^{\ast} are all behind the logarithmic terms. As a consequence, for RELU-MLP, if we do the re-parameterization trick as in Dinh et al. (2017), the change of the bound is small. Disclaim: Section 7 and 8 will be heuristic-based experiments and approximations. They are not rigorous.

An Approximate Generalization Metric

Assuming L^(w)\hat{L}(w) is locally convex around w∗w^{\ast}, so that ∇i2L^(w∗)≥0\nabla^{2}_{i}\hat{L}(w^{\ast})\geq 0 for all ii. If we look at Lemma 6, for fixed mm and nn, the only relevant term is ∑ilog⁡τiσi∗\sum_{i}\log\frac{\tau_{i}}{\sigma_{i}^{\ast}}. Replacing the optimal σ∗\sigma^{\ast}, and using τi∼∣wi∣+κγ,ϵ(wi)\tau_{i}\sim|w_{i}|+\kappa_{\gamma,\epsilon}(w_{i}) to approximate τi\tau_{i}, we come up with PAC-Bayes based Generalization metric, called pacGen,Even though we assume the local convexity in our metric, in application we may calculate the metric on every points. When ∇i2L^(w∗)+ρ(w∗)mκγ,ϵ(wi∗)<0\nabla^{2}_{i}\hat{L}(w^{\ast})+\rho(w^{\ast})\sqrt{m}\kappa_{\gamma,\epsilon}(w_{i}^{\ast})<0 we simply treat it as .

To calculate the metric on real-world data we need to estimate the diagonal elements of the Hessian ∇2L^\nabla^{2}\hat{L} as well as the Lipschitz constant ρ\rho of the Hessian. For efficiency concern we follow Adam (Kingma and Ba, 2014) and approximate ∇i2L^\nabla^{2}_{i}\hat{L} by (∇L^[i])2(\nabla\hat{L}[i])^{2}. Also we use the exponential smoothing technique with β=0.999\beta=0.999 as in (Kingma and Ba, 2014).

To estimate ρ\rho, we first estimate the Hessian of a randomly perturbed model ∇2L^(w+u)\nabla^{2}\hat{L}(w+u)In the experiment the gradients are taken w.r.t. ww instead of w+uw+u, and we ignore the difference between ∇w2L^(w+u)\nabla^{2}_{w}\hat{L}(w+u) and ∇w+u2L^(w+u)\nabla^{2}_{w+u}\hat{L}(w+u)., and then approximate ρ\rho by ρ=max⁡i∣∇i2L(w+ui)−∇i2L(w)∣∣ui∣\rho=\max_{i}\frac{|\nabla_{i}^{2}L(w+u_{i})-\nabla_{i}^{2}L(w)|}{|u_{i}|}.

We used the same model without dropout from the PyTorch example https://github.com/pytorch/examples/tree/master/mnist. We fix the learning rate as 0.10.1 and vary the batch size for training. The gap between the test loss and the training loss, and the metric Ψγ,ϵ(L^,w∗)\Psi_{\gamma,\epsilon}(\hat{L},w^{\ast}) are plotted in Figure 3. We had the same observation as in (Keskar et al., 2016) that as the batch size grows, the gap between the test loss and the training loss tends to get larger. Our proposed metric Ψγ,ϵ(L^,w∗)\Psi_{\gamma,\epsilon}(\hat{L},w^{\ast}) also shows the exact same trend. Note we do not use LR annealing heuristics as in (Goyal et al., 2017) which enables large batch training.

Similarly we also carry out experiment by fixing the training batch size as 256256, and varying the learning rate. Figure 5 shows generalization gap and Ψγ,ϵ(L^,w∗)\Psi_{\gamma,\epsilon}(\hat{L},w^{\ast}) as a function of epochs. It is observed that as the learning rate decreases, the gap between the test loss and the training loss increases. And the proposed metric Ψγ,ϵ(L^,w∗)\Psi_{\gamma,\epsilon}(\hat{L},w^{\ast}) shows similar trend compared to the actual generalization gap.

We also run the same model and experiment on CIFAR-10 (Krizhevsky et al., ) just to demonstrate the effectiveness of the metric. We observed similar trends on CIFAR-10 as shown in Figure 4 and Figure 6.

A Perturbed Optimization Algorithm

In this section we introduce a systematic way to perturb the model weights based on the PAC-Bayes bound. Again we use the same exponential smoothing technique as in Adam (Kingma and Ba, 2014) to estimate the Hessian ∇2L^\nabla^{2}\hat{L}. To make the algorithm efficient, we ignore the third order part in the bound (7) so that we do not have to estimate the Lipschitz constant ρ\rho of Hessian. The details of the algorithm is presented in (Algorithm 1), where we treat η\eta as a hyper-parameter to be optimized using the validation set.

Even though in theoretical analysis Eu[∇L^⋅u]=0E_{u}[\nabla\hat{L}\cdot u]=0, in applications, ∇L^⋅u\nabla\hat{L}\cdot u won’t be zero especially when we only implement 11 trial of perturbation. On the other hand, if the gradient ∇L^\nabla\hat{L} is close to zero, then the first order term can be ignored. As a consequence, in (Algorithm 1) we only perturb the parameters that have small gradients whose absolute value is below β2\beta_{2}. For efficiency issues we used a per-parameter ρi\rho_{i} capturing the variation of the diagonal element of Hessian. Also we decrease the perturbation level with a log factor as the epoch increases.

We compare the perturbed algorithm against the original optimization method on CIFAR-10, CIFAR-100 (Krizhevsky et al., ), and Tiny ImageNet https://tiny-imagenet.herokuapp.com/. The results are shown in Figure 7. We use the Wide-ResNet (Zagoruyko and Komodakis, 2016) as the prediction model.https://github.com/meliketoy/wide-resnet.pytorch/blob/master/networks/wide_resnet.py The depth of the chosen model is 58, and the widen-factor is set as 3. The dropout layers are turned off. For CIFAR-10 and CIFAR-100, we use Adam with a learning rate of 10−410^{-4}, and the batch size is 128. For the perturbation parameters we use η=0.01\eta=0.01, γ=10\gamma=10, and ϵ\epsilon=1e-5. For Tiny ImageNet, we use SGD with learning rate 10−210^{-2}, and the batch size is 156. For the perturbed SGD we set η=100\eta=100, γ=1\gamma=1, and ϵ\epsilon=1e-5. Also we use the validation set as the test set for the Tiny ImageNet. We observe the the effect with perturbation appears similar to regularization. With the perturbation, the accuracy on the training set tends to decrease, but the test or the validation set increases.

Conclusion

We connect the smoothness of the solution with the model generalization in the PAC-Bayes framework. We prove that the generalization power of a model is related to the Hessian and the smoothness of the solution, the scales of the parameters, as well as the number of training samples. In particular, we prove that the best perturbation level scales roughly as 1∇2L^+ρmκγ,ϵ(wi)\frac{1}{\sqrt{\nabla^{2}\hat{L}+\rho\sqrt{m}\kappa_{\gamma,\epsilon}(w_{i})}}, which mostly cancels out scaling effect in the re-parameterization suggested by (Dinh et al., 2017). To the best of our knowledge, this is the first work that integrate Hessian with the model generalization rigorously, and is also the first work explaining the effect of re-parameterization over the generalization rigorously. Based on our generalization bound, we propose a new metric to test the model generalization and a new perturbation algorithm that adjusts the perturbation levels according to the Hessian. Finally, we empirically demonstrate the effect of our algorithm is similar to a regularizer in its ability to attain better performance on unseen data.

Acknowledgement

The authors are grateful to Tengyu Ma, James Bradbury, Yingbo Zhou, and Bryan McCann for their helpful comments and suggestions on the manuscript.

References

A Proof of Lemma 6

Proof We rewrite the inequality (12) below

The terms related to σi\sigma_{i} on the right hand side of (27) are

Since the assumption is ∇i2L^(w∗)≥0\nabla^{2}_{i}\hat{L}(w^{\ast})\geq 0 for all ii, ∇i2L^(w)+ρm1/2(γ∣wi∣+ϵ)/3>0\nabla^{2}_{i}\hat{L}(w)+\rho m^{1/2}(\gamma|w_{i}|+\epsilon)/3>0. Solving for σ\sigma that minimizes the right hand side of (27), and we have

The term 16∑i∇i2L(w)σi2+ρm1/218∑i(γ∣wi∣+ϵ)σi2\frac{1}{6}\sum_{i}\nabla_{i}^{2}L(w)\sigma_{i}^{2}+\frac{\rho m^{1/2}}{18}\sum_{i}(\gamma|w_{i}|+\epsilon)\sigma_{i}^{2} on the right hand side of (12) is monotonically increasing w.r.t. σ2\sigma^{2}, so

Combine the inequality (30), and the equation (29) with (27), and we complete the proof.

B Proof of Theorem 7

The following proof is similar to the proof of Theorem 6 in (Seldin et al., 2011). Note the η\eta in Lemma (6) cannot depend on the data. In order to optimize η\eta we need to build a grid of the form

For a given value of ∑ilog⁡τiσi∗\sum_{i}\log\frac{\tau_{i}}{\sigma_{i}^{\ast}}, we pick ηj\eta_{j}, such that

where ⌊x⌋\lfloor x\rfloor is the largest integer value smaller than xx. Set δj=δ2−(j+1)\delta_{j}=\delta 2^{-(j+1)}, and take a weighted union bound over ηj\eta_{j}-s with weights 2−(j+1)2^{-(j+1)}, and we have with probability at least 1−δ1-\delta,

Simplify the right hand side and we complete the proof.

C Proof of Lemma 8

We first rewrite the inequality (21) below:

The terms related to σi\sigma_{i} on the right hand side of (21) is

Take gradients w.r.t. σi\sigma_{i}, when ∇i2L^≥0\nabla_{i}^{2}\hat{L}\geq 0, we get the optimal σi∗\sigma_{i}^{\ast},

Note the first term in (31) is monotonously increasing w.r.t. σi\sigma_{i}, so

Summing over mm parameters and combine (21), we complete the proof.

D A Lemma about Eigenvalues of Hessian and Generalization

Suppose the loss function l(f,x,y)∈l(f,x,y)\in. Let π\pi be any distribution on the parameters that is independent from the data. For any δ>0\delta>0 and η>0\eta>0, with probability at least 1−δ1-\delta over the draw of nn samples, for any local optimal w∗w^{\ast} such that ∇L^(w∗)=0\nabla\hat{L}(w^{\ast})=0, L^(w)\hat{L}(w) satisfies the local ρ\rho-Hessian Lipschitz condition in Neighγ,ϵ(w∗)Neigh_{\gamma,\epsilon}(w^{\ast}), and any random perturbation uu, s.t., ∣ui∣≤γ∣wi∗∣+ϵ  ∀i|u_{i}|\leq\gamma|w_{i}^{\ast}|+\epsilon~{}~{}\forall i, we have

Due to the linearity of the expected value,

which does not assume independence among the perturbations uiu_{i} and uju_{j} for i≠ji\neq j.