F EATURE -R OBUSTNESS , F LATNESS AND G ENERALIZATION E RROR FOR D EEP N EURAL N ETWORKS
Anonymous authors
Paper under double-blind review
A BSTRACT
The performance of deep neural networks is often attributed to their automated, taskrelated feature construction.
It remains an open question, though, why this leads to solutions with good generalization, even in cases where the number of parameters is larger than the number of samples.
Back in the 90s, Hochreiter and Schmidhuber observed that ﬂatness of the loss surface around a local minimum correlates with low generalization error.
For several ﬂatness measures, this correlation has been empirically validated.
However, it has recently been shown that existing measures of ﬂatness cannot theoretically be related to generalization: if a network uses ReLU activations, the network function can be reparameterized without changing its output in such a way that ﬂatness is changed almost arbitrarily.
This paper proposes a natural modiﬁcation of existing ﬂatness measures that results in invariance to reparameterization.
The proposed measures imply a robustness of the network to changes in the input and the hidden layers.
Connecting this feature robustness to generalization leads to a generalized deﬁnition of the representativeness of data .
With this, the generalization error of a model trained on representative data can be bounded by its feature robustness which depends on our novel ﬂatness measure.
I NTRODUCTION
Neural networks (NNs) have become the state of the art machine learning approach in many applications.
An explanation for their superior performance is attributed to their ability to automatically learn suitable features from data.
In supervised learning, these features are learned implicitly through minimizing the empirical error E emp ( f, S )
= 1 / | S | (cid:80) ( x,y ) ∈ S (cid:96) ( f ( x ) , y ) for a training set
S ⊂ X
× Y drawn iid according to a target distribution D : X × Y → [0 , 1] , and a loss function (cid:96) :
Y × Y → R + .
Here, f : X → Y denotes the function represented by a neural network.
It is an open question why minimizing the empirical error during deep neural network training leads to good generalization, even though in many cases the number of network parameters is higher than the number of training examples.
That is, why deep neural networks have a low generalization error
[Equation]
which is the difference between expected error on the target distribution D and the empirical error on a ﬁnite dataset S ⊂
X × Y .
It has been proposed that good generalization correlates with ﬂat minima of the non-convex loss surface (Hochreiter & Schmidhuber, 1997; 1995) and this correlation has been empirically validated (Keskar et al., 2016;
Novak et al., 2018; Wang et al., 2018).
Thus, for deep neural networks trained with stochastic gradient descent (SGD), this could present a (partial) explanation for their generalization performance (Zhang et al., 2016), since minibatch SGD tends to converge to ﬂat local minima (Zhang et al., 2018; Jastrz˛ebski et al., 2017).
This idea was elaborated on by Chaudhari et al.
(2016) who suggest a new training method that favors ﬂat over sharp minima even at the cost of a slightly higher empirical error – indeed solutions found by this algorithm exhibit better generalization performance.
Similarly, Dziugaite & Roy (2017) augment the loss to improve generalization and ﬁnd that this promotes ﬂat minima.
However, as Dinh et al.
(2017) remarked, current ﬂatness measures—which are based only on the Hessian of the loss function—cannot theoretically be related to generalization: For deep neural networks with ReLU activation functions, there are layer-wise reparameterizations that leave the network function unchanged (hence, also the generalization performance), but change any measure derived only from the loss Hessian.
[Figure]
Another, more intuitive explanation for generalization is that the function generalizes well if the extracted features encode a semantic similarity of the input that is robust to small changes—both in the input and the features.
This allows to generalize from the training set to novel, sufﬁciently similar data.
Starting from such a concept of robustness with respect to changes of features, we derive a measure of ﬂatness that is invariant under the mentioned reparameterizations and that reduces to the well-known ridge regression penalty in the special case of a linear regression.
This brings three seemingly related properties into our focus: ﬂatness, robustness, and generalization.
The exact relationship, however, between ﬂatness of the loss surface around local minima (measuring changes of the empirical error for perturbations in parameter space), robustness (measuring changes of the error for perturbations in either input or feature space), and generalization (performance on unseen data from the target distribution) is not well-understood.
This paper provides new insights into this relationship.
The notion of feature robustness proposed in this paper measures the robustness of a function f = ψ ◦ φ (e.g., a neural network) toward local changes in a feature space.
That is, f can be split into a composition of functions f ( x ) =
( ψ ◦ φ )( x ) for x ∈ X , φ : X → R m and ψ : R m → Y .
The function φ is considered as a feature extraction, mapping the input X into a feature space R m , while the function ψ corresponds to the model (e.g., a classiﬁer) with R m as its domain (see Figurefor illustration).
It is the feature space deﬁned by φ where we measure robustness toward small perturbations.
For neural networks, the activation values of any but the output layer can be viewed as a feature space.
A function f is called (cid:15)(cid:15)(cid:15) -feature robust on a dataset S ⊂ X
× Y if small changes in the feature space deﬁned by φ do not change the empirical error by more than (cid:15) .
This differs from the notion of robustness deﬁned by Xu & Mannor (2012) using a cover of the sample space, which has been theoretically connected to generalization.
Flatness of the loss surface, however, is a local property
and we require a more local version of robustness to derive a connection between ﬂatness and robustness.
Then, indeed, feature-robustness is upper bounded by the proposed ﬂatness measure.
To ﬁnally connect the two local properties of robustness and ﬂatness to generalization, we necessarily need a notion describing how representative the given samples are for the true distribution.
We deﬁne a suitable notion, leading to an upper bound for the generalization error given by feature robustness together with representativeness.
In summary, our contributions are as follows: (i) For models of the form f ( x ) =
( ψ ◦ φ )( x ) (e.g. most (deep) neural networks) that split up into a feature extractor φ and a model ψ on the feature space deﬁned by φ , we deﬁne a property of feature robustness that measures the change of the loss function under small perturbations of the features.
This property is strongly related to ﬂatness of the loss surface at local minima.
(ii)
We propose a novel ﬂatness measure.
For neural networks with ReLU activation functions, it is invariant under layer-wise reparameterization, addressing a shortcoming of previous measures of ﬂatness.
(iii)
We deﬁne a suitable notion of representativeness of a dataset connecting feature robustness to the generalization error in form of an upper bound.
(iv)
The proposed ﬂatness measure is empirically shown to strongly correlate with good generalization performance.
Thereby, we recover Hessian based quantities as measures of ﬂatness.
F EATURE R OBUSTNESS
We will deﬁne a notion of robustness in feature space R m for the model f = ( ψ ◦ φ ) :
X → Y , which depends on a small number δ > 0 , a training set S , and a feature selection deﬁned by a matrix
A ∈ R m × m of operator norm
||
A || ≤ 1 .
In the case of neural networks split into a composition according to Figure 1, traditionally, the activation values φ j ( x ) of neurons are considered as feature values.
The feature value deﬁned by the j -th neuron in the feature space φ ( x ) ∈ R m can be written as φ j ( x ) =
(cid:104) φ ( x ) , e j (cid:105) , where e j denotes the j -th unit vector and (cid:104)· , ·(cid:105) the scalar product in R m .
However, it was shown by Szegedy et al.
(2013) that, for any other direction v ∈ R m , ||
v || = 1 , the values (cid:104) φ ( x ) , v (cid:105) =
proj v φ ( x ) obtained from the projection φ ( x ) onto v , can be likewise semantically interpreted as a feature.
We can single out the feature deﬁned by v from φ ( x ) by multiplication with the projection matrix E v = vv T .
Similarly, multiplication of φ ( x ) with a matrix A corresponds to a weighted selection of rank ( A ) -many features in parallel (e.g., projection matrices on d-dimensional subspaces correspond to the selection of d many features).
This justiﬁes our terminology considering a matrix A as a feature selection.
The same way that, for a sample input x , non-activated neurons φ j ( x ) = 0 are considered as non-expressed features, we call a selection of features deﬁned by matrix
A as non-expressed whenever Aφ ( x ) = 0 .
We deﬁne our notion of feature robustness .
In words, feature robustness measures the mean change in loss over a dataset under small changes of features in the feature space.
Hereby, a matrix A determines which features shall be perturbed.
For each sample, the perturbation is linear in the expression of the feature.
Thereby, we only perturb features that are relevant for the output for a given sample and leave feature values unchanged that are not expressed (in the sense explained above).
With
[Equation]
( f (
[Equation] , y [Equation] , (2) the precise deﬁnition is given as follows:
Deﬁnition 1.
Let (cid:96) :
Y × Y → R + denote a loss function, δ and (cid:15) two strictly positive (small) real numbers,
S = { ( x i , y i ) | i = 1 , . .
. , N } ⊆
X × Y a set, and A ∈ R m × m a matrix
such that ||
A || ≤ 1 .
A model f ( x ) =
( ψ ◦ φ )( x ) , which is a composition of functions φ : X → R m and ψ : R m → Y , is called (( δ, S, A ) , (cid:15) )
(( δ, S, A ) , (cid:15) ) (( δ, S, A ) , (cid:15) )
-feature robust , if |F ( δ (cid:48) , S, A ) | ≤ (cid:15) for all | δ (cid:48) | ≤ δ.
More generally, if A ⊂ R m × m denotes a probability space over matrices such that
||
A || ≤for all A ∈ A , then we call the model (( δ, S, A ) , (cid:15) )
(( δ, S, A ) , (cid:15) ) (( δ, S, A ) , (cid:15) )
-feature robust on average over A , if E
A ∼A [ |F ( δ (cid:48) , S, A ) | ] ≤ (cid:15) for all | δ (cid:48) | ≤ δ.
We will bound feature robustness at local minima for a dataset S uniformly over all feature selections
A and dependent on δ .
With our interpretation, this corresponds to an upper bound of the change in loss when perturbing features in feature space R m .
In Appendix C.
we note how feature robustness is related to noise injection in the layer of consideration, which is known to be related to generalization (An, 1996; Bishop, 1995).
F EATURE R OBUSTNESS IS C ONNECTED TO F LATNESS OF THE L OSS C URVE
Consider a function f ( x, w )
=
ψ ( w , φ ( x ))
=
g ( w φ ( x )) , where ψ is the composition of a twice differentiable function g : R d → Y and a matrix product with a matrix w ∈ R d × m .
As before, φ : X → R m can be considered as a feature extractor.
We ﬁx a loss function (cid:96) :
Y × Y → R + for supervised learning and let w ∗ denote a choice of parameters for which the empirical error
E emp ( w , S ) = 1 / | S | (cid:80) ( x,y ) ∈ S (cid:96) ( f ( x, w ) , y ) , considered as a function on w , is at a local minimum on the training set S
= { ( x i , y i ) | i = 1 , . . .
, N } .
In the following, we write z = φ ( x ) .
For any matrix A ∈ R m × m we have that
[Equation]
Therefore,
[Equation]
The latter is the empirical error E emp ( w + δ w A, S ) of the model f on the dataset S at parameters w + δ w A .
If δ is sufﬁciently small, then by Taylor expansion of E emp ( w , S ) with respect to parameters w around the critical point w ∗ , we have that
[Equation]
with H E emp ( w ∗ , S ) denoting the Hessian of the empirical error with respect to w , (cid:104)· , ·(cid:105) the scalar product with vectorized versions of the parameters and || w || F the Frobenius norm of w .
Subtracting E emp ( w ∗ , S ) from (5), maximizing over matrices ||
A || ≤ 1 and using (4), we get that, for any feature selection A , the function (2) deﬁning feature robustness is bounded by
[Equation]
where λ Hmax ( w ∗ ) denotes the largest eigenvalue of the Hessian H E emp ( w ∗ , S ) of the empirical error at w ∗ .
Here we used the identity that max || x
||
=1 x T Mx = λ M max for any symmetric matrix M , and that for matrices of norm ||
A || ≤ 1 , we have || w ∗
A || F ≤ || w ∗
||
F .
We show details of the proof of (6) in the appendix.
We summarize the connection between feature robustness and ﬂatness in terms of the Hessian in the following theorem.
Theorem 2.
Let (cid:96) :
Y × Y → R + denote a loss function, δ a strictly positive (small) real number,
A ∈ R m × m a matrix with || A || ≤ 1 , and let f ( x, w )
=
g ( w φ ( x )) be a model with g an arbitrary twice differentiable function on a matrix product of parameters w and the image of x under a (feature) function φ .
Let w ∗ denote a local minimum of the empirical error on a dataset S .
Then the model f ( w ∗ ) is (( δ, S, A ) , (cid:15) )
-feature robust for (cid:15)
=
δ 2
|| w ∗
|| 2 F λ Hmax ( w ∗ )
+ O ( δ 3 ) .
M EASURES OF F LATNESS OF THE L OSS C URVE
Motivated by the relation of feature robustness with the Hessian H , we deﬁne a novel measure of ﬂatness.
Note that the Hessian is computed with respect to those parameters w that are applied linearly on the feature space φ ( X ) ⊆
R m .
Deﬁnition 3.
Let (cid:96) :
Y × Y → R + denote a loss function and f ( x, w ) =
g ( w φ ( x )) be a model with g : R m → Y an arbitrary twice differentiable function on a matrix product of parameters w and the image of x under a (feature) function φ : X → R m .
Then κ φ ( w ) shall denote a ﬂatness measure of the loss surface deﬁned by
[Equation]
Note that small values of κ φ ( w ) indicate ﬂatness and high values indicate sharpness.
Linear regression with squared loss In the case of linear regression, f ( x, w ) =
w x ∈ R ( X = R
d , g = id and φ = id ), for any loss function (cid:96) , we compute second derivatives with respect to the parameters w ∈ R d as
[Equation]
If (cid:96) is the squared loss function (cid:96) (ˆ y, y )
=
(ˆ y − y ) 2 , then ∂ 2 (cid:96) /
∂
ˆ y 2 =
and the Hessian is independent of the parameters w .
In this case, κ id = c · || w || 2 with a constant c = 2 λ max ( (cid:80) x ∈ S xx t ) and the measure κ id reduces to (a constant multiple of) the well-known Tikhonov (ridge) regression penalty.
Layers of Neural Networks We consider neural network functions
[Equation]
of a neural network of L layers with nonlinear activation function σ .
We hide a possible non-linearity at the output by integrating it in a loss function (cid:96) chosen for neural network training.
By letting φ l ( x ) = σ ( w l
[Equation]
1 σ ( . . .
σ ( w 2 σ ( w 1 x + b 1 ) + b 2 ) . . . )
+ b l − 1 ) denote the output of the composition of the ﬁrst l − 1 layers and
g l ( z ) =
w L σ ( . . .
σ ( z + b l ) . . . )
+ b L the composition of the activation function of the l -th layer together with the rest of layers, we can write for each layer l , f ( x, w l ) =
g l ( w l φ l ( x )) .
Using (7) we obtain for each layer of the neural network a measure of ﬂatness at parameter values w :
[Equation]
with λ H,lmax ( w l ) the largest eigenvalue of the Hessian of the empirical error with respect to the parameters of the l-th layer.
By Theorem 2, κ l is related to small changes of feature values in layer l .
Corollary 4.
Let f denote a neural network function of an L -layer fully connected neural network.
For each layer l, 1 ≤ l ≤ L of size n l , let A ∈ R n l × n l with || A || ≤ 1 correspond to feature selections of features in the l-th layer of the neural network.
Let w l ∗ denote weights of the l -th layer at a local minimum of the empirical error.
Then the neural network is (( δ, S, A ) , (cid:15) ) - feature robust in layer l at w ∗ for (cid:15) =
δ 2 2 κ l ( w ∗ ) + O ( δ 3 ) .
For an everywhere well-deﬁned Hessian of the loss function, we assumed our network function to be twice differentiable.
With the usual adjustments (equations only hold almost everywhere in parameter space), we can also consider neural networks with ReLU activation functions.
In this case, Dinh et al.
(2017) noted that a linear reparameterization of one layer, w l → λ w l for λ > 0 , can lead to the same network function by simultaneously multiplying another layer by the inverse of λ , w k
→ 1 / λ w k , k (cid:54) = l .
Representing the same function, the generalization performance remains unchanged.
However, this linear reparameterization changes all common measures of the Hessian of the loss.
This constitutes an issue in relating ﬂatness of the loss curve to generalization.
We counteract this behavior by the multiplication with || w l || 2 .
Theorem 5.
Let f = f ( w 1 , w 2 , . .
. , w L ) denote a neural network function parameterized by weights w l of the l -th layer.
Suppose there are positive numbers λ 1 , . .
λ L such that f ( w 1 , w 2 , . .
. , w L ) =
f ( λ 1 w 1 , λ 2 w 2 , . . .
, λ L w L ) for all w l .
Then, with w = ( w 1 , w 2 , . .
. , w L ) and w λ = ( λ 1 w 1 , λ 2 w 2 , . . .
, λ L w L ) , we have
[Equation]
We provide a proof in Appendix A.2.
An Averaging Alternative Experimental work (Ghorbani et al., 2019) suggests that the spectrum of the Hessian has a lot of small values and only a few large outliers.
In this case, our ﬂatness measure serving as an upper bound for feature robustness is governed by the outlier.
However, feature robustness for different feature selections is governed by different eigenvalues of the Hessian, according to (5).
We therefore consider the trace as an average of the spectrum.
We will show that this tracial averaging corresponds to feature robustness on average over all orthogonal feature selection matrices.
The following theorem speciﬁes this connection between feature robustness and the unnormalized trace
Tr ( H E emp ( w ∗ )) of the empirical error at a local minimum w ∗ .
The details and the proof can be found in Appendix A.3.
Theorem 6.
Let (cid:96) :
Y × Y → R + denote a loss function, δ a strictly positive (small) real number, and let f ( x, w )
=
g ( w φ ( x )) be a model with g an arbitrary twice differentiable function on a matrix product of parameters
w ∈ R d
× m and the image of x under a (feature) function φ .
Let w ∗ denote a local minimum of the empirical error on a dataset S and O m ⊂ R m × m denote the set of orthogonal matrices.
Then, (i) for each feature selection matrix
||
A || ≤ 1 the model f ( w ∗ ) is (( δ, S, A ) , (cid:15) )
-feature robust for (cid:15)
=
δ 2
|| w ∗
|| 2 F Tr ( H E emp ( w ∗ ))
+ O ( δ 3 ) , and (ii) the model f ( w ∗ ) is (( δ, S, O m ) , (cid:15) )
-feature robust on average over O m for (cid:15)
=
δ 2 2 m ||
w ∗
|| 2 F Tr ( H E emp ( w ∗ ))
+ O ( δ 3 ) .
We therefore consider the unnormalized trace as a suitable and efﬁciently computable measure of ﬂatness and deﬁne for each layer l of a neural network [Equation]
[Equation]
The same arguments as those used to prove Theorem 5 also show the measure κ lTr to be independent with respect to the same layer-wise reparameterizations.
The analogue of Corollary 4 is as follows.
Corollary 7.
Let f denote a neural network function of an L -layer fully connected neural network.
For each layer l, 1 ≤ l ≤ L of size n l , let O n l ⊂ R n l × n l denote the set of orthogonal feature selections in the l-th layer of the neural network.
Let w l ∗ ∈ R n l +1 × n l denote weights of the l -th layer at a local minimum of the empirical error.
Then the neural network is (( δ, S, O n ) , (cid:15) ) - feature robust in layer l on average over O n at w ∗ for (cid:15) =
δ 2 2 n l κ l Tr ( w ∗ ) + O ( δ 3 ) . Remark 8.
Other Hessian-based measures have been proposed that are invariant under the given reparameterizations. Liang et al. (2019) consider the Fisher-Rao norm deﬁned by || w T ˆ H ( w ) w || where ˆ H ( w ) =
( ∇ w (cid:96) )( ∇ w (cid:96) )
T denotes the Gauss-Newton approximation of the loss Hessian.
Therefore, the Fisher-Rao norm considers the second partial derivative only into the direction deﬁned by the given weight values w .
Our measure considers all directions of moving away from a local minimum.
In particular, in contrast to these measures, we take the full spectrum of the Hessian into account, which results in a natural measure of ﬂatness around a local minimum.
We also came across preprints by Tsuzuku et al.
and Rangamani et al.
(2019), which propose a similar measure of ﬂatness.
While the ﬁrst one derives the ﬂatness measure from a PAC Baysian approach, the latter considers the Riemannian metric on the quotient manifold obtained from the equivalence relation given by the refactorization of layers as above.
F EATURE R OBUSTNESS AND G ENERALIZATION
In this section we aim to study the relation between ﬂatness, feature robustness and the generalization error (deﬁned in (1)).
The connection of ﬂat local minima with generalization in PAC Baysian bounds has been considered in several works (Neyshabur et al., 2017; Tsuzuku et al., 2019; Dziugaite & Roy, 2017).
Arora et al.
(2018) relates noise injection to generalization under the same setting.
The work of McAllester (1998; 1999) and Langford & Caruana (2001) initiated the PAC-Baysian approach to generalization, which measures the generalization error (usually for the 0-1 loss) of stochastic classiﬁers.
This leads to bounds on the expected true error over a distribution of models Q in terms of the expectation of the empirical error over Q and the Kullback–Leibler divergence between Q and some prior distribution P .
For example, Neyshabur et al. (2017) use work by McAllester (2003) to derive an inequality relating the generalization error for the 0-1 loss (cid:96) and expected sharpness γ ν := E ν [ E emp ( w + ν, S )] − E emp ( w , S ) over distribution ν : With probability (1 − (cid:15) ) over datasets
S of size N , the expected error
E w + ν := E ν (cid:2)
E
( x,y ) ∼D [ (cid:96) ( f ( x, w + ν ) , y )] (cid:3) over the “posterior” distribution ( w + ν ) is bounded by E emp ( w , S ) + γ ν + 4 (cid:113) 1 N (cid:0) KL( w + ν || P ) + ln 2 N(cid:15) (cid:1) .
Here, P denotes a “prior” distribution which is ﬁxed before seeing any data and KL denotes the KullbackLeibler divergence.
If we aim to use distributions with local support (as considered in feature robustness and the Taylor expansion relating feature robustness to ﬂatness) with a data-independent prior P , the KL term goes to inﬁnity as the distribution ν becomes increasingly localized.
Since feature robustness as a local property is related to generalization (Morcos et al., 2018), we aim to connect the local properties of ﬂatness and feature robustness to generalization of a speciﬁc model by following a different approach.
Our approach will be independent of the loss function and work in the sample space instead of averages over models in parameter space.
Since feature robustness is a local property in neighborhoods around the points ( x, y ) ∈ S , to connect feature robustness to generalization we necessarily need an assumption of representativeness of the given data samples S .
A simple computation shows that
[Equation]
The ﬁrst term is exactly feature robustness on average over a probability distribution A of feature matrices.
For the second term, we accordingly deﬁne a notion on datasets S that describes how well the loss on the true distribution can be approximated by certain probability distributions.
The distributions we consider are composed of a dataset and (local) probability distributions around its points suitably restricted to local distributions
λ i and ν i centered around the origin 0 .
Deﬁnition 9.
Let ψ : R m → Y be a model, (cid:96) :
Y × Y → R + denote a loss function, (cid:15) a strictly positive (small) real number, and S
= { ( x i , y i ) | i = 1 , . . .
, N } ⊆
X × Y a set.
Let Λ
=
( λ i , ν i ) 1 ≤ i ≤ N denote a family of pairs of probability distributions on R m × Y , where each λ i
and ν
i have support contained in a neighborhood of the origin 0 .
(i)
The pair ( S, Λ) is called (cid:15)(cid:15)(cid:15) -representative for ψψψ (with respect to the loss (cid:96) and distribution D ) if | Rep ( S, Λ) | ≤ (cid:15) , where Rep ( S, Λ) :
=
E ( x,y ) ∼D
[ (cid:96)
[Equation]
( x [Equation] , y
[Equation]
14) (ii) With Ω a collection of families Λ as above and H a hypothesis space, we say that S is ( (cid:15), Ω) ( (cid:15), Ω) ( (cid:15), Ω) - representative for H if for all ψ ∈ H there is Λ ψ ∈ Ω such that ( S, Λ ψ ) is (cid:15) -representative for ψ .
Interestingly, we naturally derived a deﬁnition of representativeness which is a generalization of classical (cid:15) -representativeness
(see e.g. Deﬁnition 4.1 in (Shalev-Shwartz & Ben-David, 2014)), justifying the terminology.
Indeed, let Λ 0 denote the family of probability distributions where each λ i =
δ
and ν i = δ 0 have full weight on the origin.
Then S is ( (cid:15), { Λ 0 } ) -representative
exactly when S is (cid:15) -representative in the classical sense.
Further, if S is (cid:15) -representative
and S is ( (cid:15) (cid:48) , Ω) -representative for some Ω containing Λ 0 , then (cid:15) (cid:48) ≤ (cid:15) .
In our setting of a model f ( x ) = ( ψ ◦ φ )( x ) , which is split up into a feature extractor φ and a model ψ , we consider ( φ ( S ) , Λ) -representativeness for model ψ and speciﬁc choices for Λ =
Λ δ, A .
Here, Λ δ, A is a family of probability distributions induced by a distribution A on feature matrices
A such that ||
A || ≤ δ as follows: We assume that a Borel measure µ A is deﬁned by a probability distribution
A on matrices R m × m .
We then deﬁne Borel measures µ i on R m by µ i ( C ) =
µ A ( { A | Aφ ( x i ) ∈ C } ) for Borel sets C ⊆ R m .
Then λ i is the probability distribution deﬁned by µ i .
We ﬁx the distributions
ν i = δ 0 and denote the set containing all families of distributions ( λ i , ν i ) that can be generated this way by A δ .
The following result is a direct consequence of Equation 13 and our Deﬁnition 9.
Theorem 10.
Let f ( x ) =
( ψ ◦ φ )( x ) be a model composed of functions φ : X → R m and ψ : R m → Y .
If f is (( δ, S, A ) , (cid:15) ) -feature robust for all || A || ≤ 1 and φ ( S ) is ( (cid:15) (cid:48) , A δ ) -representative for some H containing ψ , then the generalization error of f is bounded by E gen ( f, S ) ≤ (cid:15) + (cid:15) (cid:48) .
Hence, for generalization we need a model that is feature-robust and training data that is sampled densely enough.
In the trivial case with A = δ
the distribution with full weight on the 0-matrix, we can choose δ = 0 to obtain (cid:15)
=
and E gen ≤ (cid:15) (cid:48) .
The more feature robust a model is, the larger δ we can consider to use the ﬂexibility of choosing a nontrivial A to lower the bound on representativeness and therefore the generalization error.
We hope that in future work it will be possible to ﬁnd suitable distributions
A that lead to computable generalization bounds.
E MPIRICAL E VALUATION
In this section we empirically validate the practical usefulness of the proposed ﬂatness measure.
A correlation between generalization and Hessian-based ﬂatness measures at local minima has been observed previously, but the results of Dinh et al.
(2017) questioned the usefulness of these measures.
We show that our measure does not only overcome the theoretical issues, but also preserves the strong correlation with the generalization error.
Previous works mostly use accuracy of the trained model on the testing dataset (Rangamani et al., 2019; Keskar et al., 2016) for evaluating the generalization properties of the achieved minimum.
Nevertheless this does not directly correspond to the theoretical deﬁnition of the generalization error (1).
For measuring the generalization error, we employ a Monte
Carlo approximation of the target distribution deﬁned by the testing dataset and measure the difference between loss value on this approximation and empirical error.
In order to track the correlation of the ﬂatness measure to the generalization error, sufﬁciently different minima should be achieved by training.
The most popular technique is to train the model with small and large batch size (Rangamani et al., 2019;
Keskar et al., 2016; Novak et al., 2018; Wang et al., 2018), which we also employed.
A neural network (LeNet5 (LeCun et al.)) is trained on CIFAR10 multiple times until convergence with various training setups.
This way, we obtain network conﬁgurations in multiple local minima.
In particular four different initialization schemes were considered (Xavier normal, Kaiming uniform, uniform in ( − 0 .
1 , 0 . 1) , normal with µ = 0 and σ 2 = 0 . 1 ), with four different mini-batch sizes ( 4 , 32 , 64 , 512 ) and corresponding learning rates to keep the ration between them equal ( 0 .
for the standard SGD optimizer.
Each of the setups was run for 9 times with different random initializations.
Here the generalization error is the difference between summed error values on test samples multiplied by 5 (since the size of the training set is 5 times larger) and summed error values on the training examples.
Figure 2 shows the approximated generalization error with respect to the ﬂatness measure (for both κ l and κ lTr with l = 5 corresponding to the last hidden layer) for all network conﬁgurations.
The correlation is signiﬁcant for both measures, and it is stronger (with ρ = 0 . 91 ) for κ 5 Tr .
This indicates that taking into account the full spectrum of the Hessian is beneﬁcial.
To investigate the invariance of the proposed measure to reparameterization, we apply the reparameterization discussed in Sec.
4 to all networks using random factors in the interval [5 , 25] .
The impact of the reparameterization on the proposed ﬂatness measure based on the trace in comparison to the traditional one is shown in Figure 3.
While the proposed ﬂatness measure is not affected, the one purely based on the Hessian has very weak correlation with the generalization error after the modiﬁcations.
To verify the relation described by Equation 6, we also compared feature robustness with δ = 0 .and
feature matrices
A that have only one non-zero value 1 on the diagonal.
Figure 4 shows that up to outliers the robustness is bound by the ﬂatness measure.
Additional experiments conducted on MNIST dataset are described in Appendix E where we obtain correlation factors between the generalization error and tracial ﬂatness κ lTr of 0 .
71 for the network’s hidden layers l = 1 , 2 , 3 , 4 respectively.
D ISCUSSION AND C ONCLUSION
We established a theoretical connection between ﬂatness, feature robustness and, under the assumption of representative data, the generalization error.
The relation between feature robustness and Hessianbased ﬂatness measures has been established for κ l , which takes into account the maximum eigenvalue of the Hessian, and κ lTr , which uses the trace instead.
Empirically, the measure κ lTr based on the trace of the Hessian shows a stronger correlation with the generalization error.
This is not surprising, since it takes into account the whole spectrum of the Hessian and every eigenvalue corresponds to a feature selection matrix of feature robustness.
The tracial measure can be related to feature robustness by either bounding the maximum eigenvalue of the loss Hessian by its unnormalized trace or by averaging feature robustness over all orthogonal matrices A ∈
O m .
It is interesting to note that strong feature robustness does not exclude the possibility of adversarial examples, ﬁrst observed by Szegedy et al.
(2013), since large changes of loss for individual samples (i.e. adversarial examples) may be hidden in the mean in the deﬁnition of feature robustness.
In Appendix C.2 we brieﬂy discuss the freedom of perturbing individual points by suitable feature selection matrices A .
In contrast to existing measures of ﬂatness, our proposed measure is invariant to layer-wise reparameterizations of ReLU networks.
However, we note that other reparameterizations are possible, e.g., we can use the positive homogeneity and multiply all incoming weights into a single neuron by a positive number λ > 0 and multiply all outgoing weights of the same neuron by 1 / λ .
While the Fisher-Rao norm suggested by Liang et al.
(2019) is invariant to such reparameterizations, our proposed measures of ﬂatness κ l and κ lTr are in general not.
In principle, variations of our ﬂatness measures can be found that are invariant to such reparameterizations as well (see Appendix B) but their analysis, except for some empirical evaluations in Appendix E, is left for future work.
The second term in the generalization bound of Theorem 10 is given by our notion of representativeness.
In order to ﬁnd speciﬁc bounds for the (cid:15) -representativeness of ( S, A δ ) , a distribution over matrices is required that induces a distribution which is similar to a localized kernel density estimation (KDE).
While our notion of representativeness is a generalization of classical representativeness, it remains open whether it is efﬁciently computable.
The more feature robust a model is, the more freedom there is to ﬁnding speciﬁc distributions over matrices that lead to bounds on the generalization error.
In Appendix D we give a computation of representativeness for a KDE with Gaussian kernels.
Taking things together, we proposed a novel and practically useful ﬂatness measure that strongly correlates with the generalization error.
We theoretically investigated this connection by relating this measure to feature robustness.
This notion of robustness, together with a novel notion of representativeness provides a link to the generalization error.
To the best of our knowledge, this yields the ﬁrst theoretical connection between a notion of robustness, ﬂatness of the loss surface, and generalization error and can help to better understand the performance of deep neural networks.
[-=
-]
[-=
-]
[-=
-]
[-[ z i z j ] = 
-]
[-=
-]
[-i 
-]
[-there is a matrix A such that Ax i 
-]