Feature-Robustness, Flatness and Generalization Error for Deep Neural Networks

1 INTRODUCTION . 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 Eemp ( f , S ) = 1/|S| ∑ ( x , y ) ∈S ` ( 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 ` : 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 Egen = E ( x , y ) ∼D [ ` ( f ( x ) , y ) ] − 1 |S| ∑ ( x , y ) ∈S ` ( f ( x ) , y ) ( 1 ) which is the difference between expected error on the target distribution D and the empirical error on a finite dataset S ⊂ X × Y . It has been proposed that good generalization correlates with flat 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 flat local minima ( Zhang et al. , 2018 ; Jastrzębski et al. , 2017 ) . This idea was elaborated on by Chaudhari et al . ( 2016 ) who suggest a new training method that favors flat 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 find that this promotes flat minima . However , as Dinh et al . ( 2017 ) remarked , current flatness measures—which are based only on the Hessian of the loss function— can not 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 . 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 , sufficiently similar data . Starting from such a concept of robustness with respect to changes of features , we derive a measure of flatness 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 : flatness , robustness , and generalization . The exact relationship , however , between flatness 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 → Rm and ψ : Rm → Y . The function φ is considered as a feature extraction , mapping the input X into a feature space Rm , while the function ψ corresponds to the model ( e.g. , a classifier ) with Rm as its domain ( see Figure 1 for illustration ) . It is the feature space defined 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 -feature robust on a dataset S ⊂ X × Y if small changes in the feature space defined by φ do not change the empirical error by more than . This differs from the notion of robustness defined 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 flatness and robustness . Then , indeed , feature-robustness is upper bounded by the proposed flatness measure . To finally connect the two local properties of robustness and flatness to generalization , we necessarily need a notion describing how representative the given samples are for the true distribution . We define 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 defined by φ , we define 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 flatness of the loss surface at local minima . ( ii ) We propose a novel flatness measure . For neural networks with ReLU activation functions , it is invariant under layer-wise reparameterization , addressing a shortcoming of previous measures of flatness . ( iii ) We define a suitable notion of representativeness of a dataset connecting feature robustness to the generalization error in form of an upper bound . ( iv ) The proposed flatness measure is empirically shown to strongly correlate with good generalization performance . Thereby , we recover Hessian based quantities as measures of flatness . 2 FEATURE ROBUSTNESS . We will define a notion of robustness in feature space Rm for the model f = ( ψ ◦ φ ) : X → Y , which depends on a small number δ > 0 , a training set S , and a feature selection defined by a matrix A ∈ Rm×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 defined by the j-th neuron in the feature space φ ( x ) ∈ Rm can be written as φj ( x ) = 〈φ ( x ) , ej〉 , where ej denotes the j-th unit vector and 〈· , ·〉 the scalar product in Rm . However , it was shown by Szegedy et al . ( 2013 ) that , for any other direction v ∈ Rm , ||v|| = 1 , the values 〈φ ( x ) , v〉 = projvφ ( x ) obtained from the projection φ ( x ) onto v , can be likewise semantically interpreted as a feature . We can single out the feature defined by v from φ ( x ) by multiplication with the projection matrix Ev = vvT . 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 justifies 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 defined by matrix A as non-expressed whenever Aφ ( x ) = 0 . We define 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 F ( δ , S , A ) : = 1 |S| ∑ ( x , y ) ∈S [ ` ( ψ ( φ ( x ) + δAφ ( x ) ) , y ) − ` ( f ( x ) , y ) ] , ( 2 ) the precise definition is given as follows : Definition 1 . Let ` : Y × Y → R+ denote a loss function , δ and two strictly positive ( small ) real numbers , S = { ( xi , yi ) | i = 1 , . . . , N } ⊆ X × Y a set , and A ∈ Rm×m a matrix such that ||A|| ≤ 1 . A model f ( x ) = ( ψ ◦ φ ) ( x ) , which is a composition of functions φ : X → Rm and ψ : Rm → Y , is called ( ( δ , S , A ) , ) -feature robust , if |F ( δ′ , S , A ) | ≤ for all |δ′| ≤ δ . More generally , if A ⊂ Rm×m denotes a probability space over matrices such that ||A|| ≤ 1 for all A ∈ A , then we call the model ( ( δ , S , A ) , ) -feature robust on average over A , if EA∼A [ |F ( δ′ , S , A ) | ] ≤ for all |δ′| ≤ δ . 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 Rm . In Appendix C.1 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 ) . 3 FEATURE ROBUSTNESS IS CONNECTED TO FLATNESS OF THE LOSS CURVE . Consider a function f ( x , w ) = ψ ( w , φ ( x ) ) = g ( wφ ( x ) ) , where ψ is the composition of a twice differentiable function g : Rd → Y and a matrix product with a matrix w ∈ Rd×m . As before , φ : X → Rm can be considered as a feature extractor . We fix a loss function ` : Y × Y → R+ for supervised learning and let w∗ denote a choice of parameters for which the empirical error Eemp ( w , S ) = 1/|S| ∑ ( x , y ) ∈S ` ( f ( x , w ) , y ) , considered as a function on w , is at a local minimum on the training set S = { ( xi , yi ) | i = 1 , . . . , N } . In the following , we write z = φ ( x ) . For any matrix A ∈ Rm×m we have that ψ ( w , z + δAz ) = g ( w ( z + δAz ) ) = g ( ( w + δwA ) z ) = ψ ( w + δwA , z ) . ( 3 ) Therefore , F ( δ , S , A ) + Eemp ( w , S ) = 1 |S| ∑ ( x , y ) ∈S ` ( ψ ( w , z +Aδz ) , y ) = 1 |S| ∑ ( x , y ) ∈S ` ( ψ ( w + δwA , z ) , y ) . ( 4 ) The latter is the empirical error Eemp ( w + δwA , S ) of the model f on the dataset S at parameters w + δwA . If δ is sufficiently small , then by Taylor expansion of Eemp ( w , S ) with respect to parameters w around the critical point w∗ , we have that Eemp ( w∗ + δw∗A , S ) = Eemp ( w∗ , S ) + 〈δw∗A , ∇Eemp ( w∗ , S ) 〉 + 1 2 〈δw∗A , HEemp ( w∗ , S ) · ( δw∗A ) 〉+O ( δ3||w∗A||3F ) = Eemp ( w∗ , S ) + δ2 2 〈w∗A , HEemp ( w∗ , S ) · ( w∗A ) 〉+O ( δ3||w∗A||3F ) ( 5 ) with HEemp ( w∗ , S ) denoting the Hessian of the empirical error with respect to w , 〈· , ·〉 the scalar product with vectorized versions of the parameters and ||w||F the Frobenius norm of w. Subtracting Eemp ( w∗ , S ) from ( 5 ) , maximizing over matrices ||A|| ≤ 1 and using ( 4 ) , we get that , for any feature selection A , the function ( 2 ) defining feature robustness is bounded by max ||A||≤1 F ( δ , S , A ) ≤ δ 2 2 ||w∗||2F λHmax ( w∗ ) +O ( δ3 ) ( 6 ) where λHmax ( w∗ ) denotes the largest eigenvalue of the Hessian HEemp ( w∗ , S ) of the empirical error at w∗ . Here we used the identity that max||x||=1 xTMx = λMmax 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 flatness in terms of the Hessian in the following theorem . Theorem 2 . Let ` : Y × Y → R+ denote a loss function , δ a strictly positive ( small ) real number , A ∈ Rm×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 ) , ) -feature robust for = δ 2 2 ||w∗|| 2 F λ H max ( w∗ ) +O ( δ3 ) .

Summary: This paper describes a connection between flatness of minima and generalization in deep neural networks. The authors define a concept called "feature-robustness" and show that it is related to flatness. This is derived through a straightforward observation that perturbations in feature space can be recast as perturbations of the model in parameter space. This allows the authors to define a (layerwise) flatness measure for minima in deep networks (this layerwise flatness measure is also invariant to rescalings of the layers in neural networks with positively homogenous activations). The authors combine their notion of feature robustness with epsilon representativeness of a function to connect flatness to generalization. They present a few empirical evaluations on CIFAR10 and MNIST.