F ORMALIZING G ENERALIZATION AND R OBUSTNESS OF N EURAL N ETWORKS TO W EIGHT P ERTURBATIONS
Anonymous authors
Paper under double-blind review
A BSTRACT
Studying the sensitivity of weight perturbation in neural networks and its impacts on model performance, including generalization and robustness, is an active research topic due to its implications on a wide range of machine learning tasks such as model compression, generalization gap assessment, and adversarial attacks.
In this paper, we provide the ﬁrst formal analysis for feed-forward neural networks with non-negative monotone activation functions against norm-bounded weight perturbations, in terms of the robustness in pairwise class margin functions and the Rademacher complexity for generalization.
We further design a new theory-driven loss function for training generalizable and robust neural networks against weight perturbations.
Empirical experiments are conducted to validate our theoretical analysis.
Our results offer fundamental insights for characterizing the generalization and robustness of neural networks against weight perturbations.
I NTRODUCTION
Neural network is currently the state-of-the-art machine learning model in a variety of tasks, including computer vision, natural language processing and game-playing, to name a few.
In particular, feed-forward neural networks consists of layers of trainable model weights and activation functions with the premise of learning informative data representations and the complex mapping between data samples and the associated labels.
Albeit attaining superior performance, the need for studying the sensitivity of neural networks to weight perturbations is also intensifying owing to several practical motivations.
For instance, in model compression, the robustness to weight quantiﬁcation is crucial for reducing memory storage while retaining model performance (Hubara et al., 2017; Weng et al., 2020).
The notion of weight perturbation sensitivity is also used as a metric to evaluate the generalization gap at local minima (Keskar et al., 2017; Neyshabur et al., 2017).
In adversarial robustness and security, weight sensitivity can be leveraged as a vulnerability for fault injection and causing erroneous prediction (Liu et al., 2017; Zhao et al., 2019).
However, while weight sensitivity plays an important role in many machine learning tasks and problem setups, theoretical characterization of its impacts on generalization and robustness of neural networks remains elusive.
This paper bridges this gap by developing a novel theoretical framework for understanding the generalization gap (through Rademacher complexity) and the robustness (through classiﬁcation margin) of neural networks against norm-bounded weight perturbations.
Speciﬁcally, we consider the multiclass classiﬁcation problem setup and multi-layer feed-forward neural networks with non-negative monotonic activation functions.
Our analysis offers fundamental insights into how weight perturbation affects the generalization gap and the pairwise class margin.
To the best of our knowledge, this study is the ﬁrst work that provides a comprehensive theoretical characterization of the interplay between weight perturbation, robustness in classiﬁcation margin, and generalization gap.
Moreover, based on our analysis, we propose a theory-driven loss function for training generalizable and robust neural networks against norm-bounded weight perturbations.
We validate its effectiveness via empirical experiments.
We summarize our main contributions as follows
• We study the robustness (worst-case bound) of the pairwise class margin function against weight perturbations in neural networks, including the analysis of single-layer (Theorem 1), all-layer (Theorem 2), and selected-layer (Theorem 3) weight perturbations.
• We characterize the generalization behavior of robust surrogate loss for neural networks under weight perturbations (Section 3.4) through Rademacher complexity (Theorem 4).
• We propose a theory-driven loss design for training generalizable and robust neural networks (Section 3.5).
The empirical results in Section 4 validate our theoretical analysis and demonstrate the effectiveness of improving generalization and robustness against weight perturbations.
R ELATED W ORKS
In model compression, the robustness to weight quantization is critical to reducing memory size and accesses for low-precision inference and training (Hubara et al., 2017).
Weng et al.
(2020) showed that incorporating weight perturbation sensitivity into training can better retain model performance (standard accuracy) after quantization.
For studying the generalization of neural networks,
Keskar et al.
(2017) proposed a metric called sharpness (or weight sensitivity) by perturbing the learned model weights around the local minima of the loss landscape for generalization assessment while An (1996) introduced weight noise into the training process and concluded that random noise training improves the overall generalization.
Neyshabur et al.
(2017) made a connection between sharpness and PAC-Bayes theory and found that some combination of sharpness and norms on the model weights may capture the generalization behavior of neural networks.
Additionally,
Bartlett et al.
(2017) discovered normalized margin measure to be useful towards quantifying generalization property and a bound was therefore constructed to give an quantitative description on the generalization gap.
Moreover, Golowich et al.
(2019) incorporated additional assumptions to offer tighter and size-independent bounds from the setting of (Neyshabur et al., 2015) and (Bartlett et al., 2017) respectively.
Despite development of various generalization bounds, empirical observations in (Nagarajan & Kolter, 2019) showed that once the size of the training dataset grows, generalization bounds proposed in (Neyshabur et al., 2017) and (Bartlett et al., 2017) will enlarge thus become vacuous.
Discussions on the relation between (Nagarajan & Kolter, 2019) and our works can be found at Appendix E, where we show that in our studied setting the associated generalization bounds are non-vacuous.
On the other hand, Barron & Klusowski (2018) and Theisen et al.
(2019) applied several techniques in tandem with a probabilistic method named path sampling to construct a representing set of given neural networks for approximating and studying the generalization property.
Another approach considered by Petzka et al.
(2020) consists of segmenting the neural networks into two functions, predictor and feature selection respectively where two measures (representativeness and feature robustness) concerning these aforementioned functions were later combined to offer a meaningful generalization bound.
However, these works only focused on the generalization behavior of the local minima and did not consider the generalization and robustness under weight perturbations.
Weng et al.
(2020) proposed a certiﬁcation method for weight perturbation retaining consistent model prediction.
While the certiﬁcation bound can be used to train robust models with interval bound propagation (Gowal et al., 2019), it requires additional optimization subroutine and computation costs when comparing to our approach.
Moreover, the convoluted nature of certiﬁcation bound complicates the analysis when studying generalization, which is one of our main objectives.
In adversarial robustness, fault-injection attacks are known to inject errors to model weights at the inference phase and causing erroneous model prediction (Liu et al., 2017; Zhao et al., 2019), which can be realized at the hardware level by changing or ﬂipping the logic values of the corresponding bits and thus modifying the model parameters saved in memory (Barenghi et al., 2012; Van Der Veen et al., 2016).
Zhao et al.
(2020) proposed to use the mode connectivity of the model parameters in the loss landscape for mitigating such weight-perturbation-based adversarial attacks.
Although, to the best of our knowledge, theoretical characterization of generalization and robustness for neural networks against weight perturbations remains elusive, recent works have studied these properties under another scenario – the input perturbations.
Both empirical and theoretical evidence have been given to the existence of a fundamental trade-off between generalization and robustness against norm-bounded input perturbations (Xu & Mannor, 2012;
Su et al., 2018; Zhang et al., 2019;
Tsipras et al., 2019).
The adversarial training proposed in (Madry et al., 2018) is a popular training strategy for training robust models against input perturbations, where a min-max optimization principle is used to minimize the worst-case input perturbations of a data batch during model parameter updates.
For adversarial training with input perturbations, Wang et al.
(2019) proved its convergence and Yin et al.
(2019) derived bounds on its Rademacher complexity for generalization.
Different from the case of input perturbation, we note that min-max optimization on neural network training subject to weight perturbation is not straightforward, as the minimization and maximization steps are both taken on the model parameters.
In this paper, we disentangle the min-max formulation for weight perturbation by developing bounds for the inner maximization step and provide quantiﬁable metrics for training generalization and robust neural networks against weight perturbations.
M AIN R ESULTS
We provide an overview of the presentation ﬂow for our main results as follows.
First, we introduce the mathematical notations and preliminary information in Section 3.1.
In Section 3.2, we establish our weight perturbation analysis on a simpliﬁed case of single-layer perturbation.
We then use the single-layer analysis as a building block and extend the results to the multi-layer perturbation setting in Section 3.3.
In Section 3.4, we deﬁne the framework of robust training with surrogate loss and study the generalization property using Rademacher complexity.
Finally, we propose a theory-driven loss toward training robust and generalizable neural networks in Section 3.5.
3. N OTATION AND P RELIMINARIES
Notation We start by introducing the mathematical notations used in this paper.
We deﬁne the set [ L ] := { 1 , 2 , ..., L } .
For any two non-empty sets A , B , F A (cid:55)→ B denotes the set of all functions from A to B .
We mark the indicator function of an event E as 1 ( E ) , which is 1 if E holds and 0 otherwise.
We use sgn ( · ) to denote element-wise sign function that outputs 1 when input is nonnegative and -1 otherwise.
Boldface lowercase letters are used to denote vectors (e.g., x ), and the i -th element is denoted as [ x ] i .
Matrices are presented as boldface uppercase letters, say W .
Given a matrix W ∈ R k × d , we write its i -th row, j -th column and ( i, j ) element as W i, : , W : ,j , and W i,j respectively.
Moreover, we write its transpose matrix as ( W ) T .
The matrix ( p, q ) norm is deﬁned as (cid:107) W (cid:107) p,q :=
(cid:13)(cid:13)(cid:13) [ (cid:107) W : , 1 (cid:107) p , (cid:107) W : , 2 (cid:107) p , ..., (cid:107) W : ,d (cid:107) p ] (cid:13)(cid:13)(cid:13) q for any p, q ≥ 1 .
For convenience, we have (cid:107) W (cid:107) p
= (cid:107) W (cid:107) p,p and write the spectral norm and Frobenius norm as (cid:107) W (cid:107) σ and (cid:107) W (cid:107) F respectively.
We mark one matrix norm commonly used in this paper – the matrix (1 , ∞ ) norm.
With a matrix W , we express its matrix (1 , ∞ ) norm as (cid:107) W (cid:107) 1 , ∞ , which is deﬁned as (cid:107) W (cid:107) 1 , ∞ = max j (cid:107) W : ,j (cid:107) 1 and (cid:13)(cid:13) W T (cid:13)(cid:13) 1 , ∞ =
max i (cid:107) W i, : (cid:107) 1 .
We use IB ∞ W ( (cid:15) ) to express an element-wise (cid:96) ∞ norm ball of matrix W within radius (cid:15) , i.e., IB ∞ W ( (cid:15) )
= { ˆ W | | ˆ W i,j − W i,j | ≤ (cid:15), ∀ i ∈ [ k ] ,
j ∈ [ d ] } .
Preliminaries In order to formally explain our theoretical results, we introduce the considered learning problem, neural network model and complexity deﬁnition.
Let X
and Y be the feature space and label space, respectively.
We place the assumption that all data are drawn from an unknown distribution D over X × Y and each data point is generated under i.i.d condition.
In this paper, we speciﬁcally consider the feature space X as a subset of d -dimensional Euclidean space, i.e.,
X ⊆ R d .
We denote the symbol F ⊆ F X(cid:55)→Y to be the hypothesis class which we use to make predictions.
Furthermore, we consider a loss function (cid:96) :
X × Y −→ [0 , 1] and compose it with the hypothesis class to make a function family written as (cid:96) F :=
{ ( x , y ) −→ (cid:96) ( f ( x ) , y ) | f ∈ F} .
The optimal solution of this learning problem is a function f ∗ ∈ F such that it minimizes the population risk R ( f ) =
E ( x ,y ) ∼D
[ (cid:96) ( f ( x ) , y )] .
However, since the underlying data distribution is generally unknown, one typically aims at reducing the empirical risk evaluated by a set of training data { ( x i , y i ) } ni =1 , which can be expressed as R n ( f ) = 1 n (cid:80) ni
=1 (cid:96) ( f ( x i ) , y i ) .
The generalization error is the gap between population and empirical risk, which could serve as an indicator of model’s performance under unseen data from identical distribution D .
To study the generalization error, one would explore the learning capacity of a certain hypothesis class.
In this paper, we adopt the notion of Rademacher complexity as a measure of learning capacity, which is widely used in statistical machine learning literature (Mohri et al., 2018).
The empirical Rademacher complexity of a function class F given a set of samples S =
{ ( x i , y i ) } ni =1 is
[Equation]
where { ν i } ni =1 is a set of i.i.d Rademacher random variables with P { ν i = − 1 }
= P { ν i = +1 } = 12 .
The empirical Rademacher complexity measures on average how well a function class F correlates with random noises on dataset S .
Thus, a richer or more complex family could better correlate with random noise on average.
With Rademacher complexity as a toolkit, one can develop the follow- ing relationship between generalization error and complexity measure.
Speciﬁcally, it is shown in (Mohri et al., 2018) that given a set of training samples S and assume that the range of loss function (cid:96) ( f ( x ) , y ) is [0 , 1] .
Then for any δ ∈ (0 , 1) , with at least probability 1 − δ we have ∀ f ∈ F R [Equation] R n
[Equation]
Note that when the Rademacher complexity is small, it is then viable to learn the hypothesis class F by minimizing the empirical risk and thus effectively reducing the generalization gap.
Finally, we deﬁne the structure of neural networks and introduce a few related quantities.
The problem studied in this paper is a multi-class classiﬁcation task with the number of classes being K .
Consider an input vector x ∈ X ⊆ R d , an L-layer neural network is deﬁned as
[Equation]
with W being the set containing all weight matrices, i.e., W :=
{ W i | ∀ i ∈
[ L ] } , and the notation ρ ( · ) is used to express any non-negative monotone activation function and we further assume that ρ ( · ) is 1-Lipschitz, which includes popular activation functions such as ReLU applied element-wise on a vector.
Moreover, the i -th component of neural networks’ output is written as f i W ( x ) =
[ f W ( x )]
i and a pairwise margin between i -th and j -th class, denoted as f ij W ( x ) :
= f j W ( x ) − f j W ( x ) , is said to be the difference between two classes in output of the neural network.
Lastly, we use the notion of z k and ˆ z k to represent the output vector of the k -th layer ( k ∈ [ L − 1] ) under natural and weight perturbed settings respectively, which are z k
= ρ
( W k ( ...ρ ( W 1 x ) ... )) and ˆ z k
= ρ
( ˆ W k ( ...ρ ( ˆ W 1 x ) ... )) , where ˆ W i ∈ IB ∞ W i ( (cid:15) i ) denotes the perturbed weight matrix bounded by its element-wise (cid:96) ∞ -norm with radius (cid:15)
i for some i ∈
[ k ] .
3. B UILDING B LOCK : S INGLE -L AYER W EIGHT P ERTURBATION
We study the sensitivity of neural network to weight perturbations through the pairwise margin bound f ij W ( x ) .
Speciﬁcally, when i and j corresponds to the top-1 and the second-top class prediction of x , respectively, the margin can be used as an indicator of robust prediction under weight perturbation to W .
For ease of understanding, we ﬁrst consider a simple example with a three-layer neural network and explain the bound through the error propagation incurred by weight perturbation.
We deﬁne the neural network as f W ( x ) =
W 3 ρ ( W 2 ρ ( ˆ W 1 x )) with W i being the weight matrix of the i -th layer and assume that one could only perturb any element in the ﬁrst weight matrix within an (cid:96) ∞ norm ball of radius (cid:15) , i.e., ˆ W 1 ∈ IB ∞ W 1 ( (cid:15) ) .
We also deﬁne an error vector as e i , which stands for the entry-wise error after propagating through the i -th layer.
Since no perturbations happened prior to the ﬁrst layer, we would directly take input vector x and derive an upper bound on the entry-wise error e 1 .
While every element in the ﬁrst weight matrix is allowed to change its magnitude by at most (cid:15) , the maximum error for any entry by matrix-vector multiplication becomes
[Equation]
Since the following layer weight is not subject to perturbation [Equation] we simply take the magnitude of each element in the subsequent weight matrix to calculate the next error vector.
In this case, we have the next layer’s error e 2 with W 2 as [ e 2 ]
i = (cid:80) j | W 2 i,j | [ e 1 ] j = (cid:15) (cid:107) x (cid:107) 1 (cid:80) j | W 2 i,j | .
Eventually, with error propagation over layers, we arrive at the ﬁnal layer and are able to assess the maximum change of any entry in output value.
By recalling the pairwise class margin f ij W ( x ) [Equation] we would like to inspect the relative change in error between any two classes.
Speciﬁcally, we derive an upper bound on the pairwise margin between any two classes α and β .
In the above example, the difference in entry-wise maximum error can be deduced in the following manner:
[Equation]
where inequality ( i ) comes from triangle inequality and inequality ( ii ) results from taking the row in W 2 with maximum (cid:96) 1 norm.
It is worth noting that there exist possible scenarios for the above inequalities to hold and therefore achieving the worst-case error.
Speciﬁcally, using the example in
Section 3.2, as we trace down the associated inequality bound in (i), we see that the ﬁrst inequality can be achieved when the ﬁnal weight layer possesses all positive weights and that the row associated with label α is greater than label β in all individual entries.
Furthermore, as long as the second weight matrix W 2 has equal (cid:96) 1 norm throughout all rows, we can then tighten the bound to give the worst-case error in (ii).
Nevertheless, we could see from the above example that the difference of maximum error between entries in output would be propagating at the rate of weight matrices’ (1 , ∞ ) norm.
By utilizing this essential concept, we introduce the ﬁrst theorem of our results, which provides an upper bound on the pairwise margin under single-layer weight perturbation.
Theorem 1 ( N -th layer weight perturbation ( N (cid:54) =
L ))
Let f W ( x )
=
W L ( ...ρ ( W 1 x ) ... ) denote an L -layer neural network and let f (cid:99) W ( x ) =
W L ( .. ˆ W N ...ρ ( W 1 x ) ... ) with ˆ W N ∈ IB ∞ W N ( (cid:15) ) , N (cid:54) =
L , denote the corresponding network subject to N -th layer perturbation.
For any set of perturbed and unperturbed pairwise margin f ij (cid:99) W ( x ) and f ij W ( x ) , we have
[Equation]
[Table]
where z k = ρ
( W k ( ...ρ ( W 1 x ) ... )) .
Proof : See Appendix A.
Since the ﬁnal layer does not have any activation function, the margin bound on the margin difference when only perturbing the ﬁnal layer can be simply derived, which is given in the following lemma.
Lemma 1 (Final-layer weight perturbation) Consider the case N =
L in Theorem 1, we have f ij [Equation]
1 , where z L − 1 is the output of the ( L − 1) -th layer.
Proof : See Appendix A.1.
3. G ENERAL S ETTING : M ULTI -L AYER W EIGHT P ERTURBATION
With the developed single-layer analysis in Section 3.2 as a building block, we now extend our analysis to the general setting of multi-layer weight perturbation, which is further divided into two cases: (i) the case of perturbing all L layers; and (ii) the case of perturbing I out of L layers.
3.3. P ERTURBING A LL L AYERS
Once equipped with the concept of error propagation over subsequent layers, we consider the scenario where every layer in a neural network is subject to weight perturbation.
We denote the model under this circumstance as the all-perturbed setting.
The following theorem states an upper bound on the pairwise margin between the natural (unperturbed) and all-perturbed settings.
Theorem 2 (all-layer perturbation) Let f W ( x ) =
W L ( ...ρ ( W 1 x ) ... ) denote an L -layer (natural) neural network and let f (cid:99) W ( x ) =
ˆ W L ( .. ˆ W N ...ρ ( ˆ W 1 x ) ... ) with ˆ W m ∈ IB ∞
W m ( (cid:15) i ) , ∀ m ∈
[ L ] , denote its perturbed version.
For any set of pairwise margin f ij (cid:99) W ( x ) and f ij W ( x ) , we have
[Equation] where z k ∗ =
ρ ( W k ∗ ...
ρ ( W 1 ∗ x ) with W m ∗ deﬁned as (cid:40) W m ∗ i,j = W mi,j + (cid:15) m , ∀ i, j and ∀ m ∈
[ L ] \ { 1 } W 1 ∗
[Equation]
[Equation]
=
[Equation]
1 i,
[Equation]
+ sgn
([ x ] j
[Equation]
(cid:15) 1 , ∀ i, j
Proof : See Appendix A.2.2.
Here, we provide some intuition on deriving the upper bound of the margin in the all-perturbed setting.
The scheme behind this all-perturbed scenario can be viewed as an inductive layer-wise error propagation.
Speciﬁcally, we can choose any perturbed layer as the commencement point of propagation, then ﬁx any other weight matrices’ values and further calculate the propagation of error from that layer using the concept in Section 3.2.
In such manner, after iterating through all these weight matrices subject to weight perturbation, one could obtain the ﬁnal change in output value and therefore establish the pairwise margin bound.
A close inspection of the bound shows that the propagation of error causes the ﬁrst term since the input layer and the rest of the terms are errors propagating since the i -th layer in the neural network, where i ∈
[ L ] .
3.3. P ERTURBING M ULTIPLE L AYERS
The all-perturbed setting is a special case of perturbing layers from an index set I when I =
[ L ] .
We extend our analysis to the general multi-layer weight perturbation setting with I ⊆
[ L ] , which includes the single-layer setting ( I = { N } ) and all-perturbed setting ( I =
[ L ] ) as special cases.
Theorem 3 (multiple-layer perturbation) Let an L-Layer neural network be written as f W ( x ) =
W L ( ...ρ ( W 1 x ) ... ) .
Given an index set I ⊆
[ L ] , we deﬁne the perturbed neural network as
[Equation]
[Equation]
) with
[Equation]
for any pairwise margin between f ij (cid:99) W ( x ) and f ij W ( x ) we have
[Equation]
[Table] f
[Table]
+
[Table]
W Li
[Table]
W Lj
[Table]
∈
I )
[Table]
where z k ∗ =
ρ ( W k ∗ ...
ρ ( W 1 ∗ x ) with W m ∗ deﬁned as  
W m ∗ i,j =  
W mi,j + (cid:15) m , ∀ i, j ∀ m ∈
[ L ] ∩ I \ { 1 }
W mi,j , ∀ i, j ∀ m ∈
[ L ] \ ( I ∪ { 1 } )
W 1 ∗ i,j = (cid:40)
W 1 i,j + sgn ([ x ] j ) (cid:15) 1 , ∀ i, j if 1 ∈
I
W 1 i,j , ∀ i, j otherwise and z 0 ∗ = x
Proof : See Appendix A.2.3.
3. S URROGATE L OSS AND G ENERALIZATION B OUND 3.4. C ONSTRUCTION OF R OBUST S URROGATE L OSS ON P AIRWISE M ARGIN
We aim to construct a surrogate loss function based on a standard loss function and study its behavior against weight perturbations.
Speciﬁcally, given a perturbation radius (cid:15) and the original loss function (cid:96) ( f W ( x ) , y ) , robust training aims to minimize the following objective function:
[Equation]
which we call it as the robustness (worst-case) loss.
Even for a single data point ( x , y ) , it is hard to assess the exact robustness loss since it requires the maximization of a non-concave function over a norm ball.
To make the problem of robust training against weight perturbations more computationally tractable, we aim to design a surrogate loss as an upper bound on the worst-case loss.
We focus on the construction of surrogate loss by means of pairwise margin bound in Section 3.3.
We ﬁrst deﬁne mathematically two popular loss functions in the classiﬁcation problem, ramp loss and cross entropy, and derive their surrogate versions.
Deﬁne the margin function M ( f W ( x ) , y ) as
[Equation]
The ramp loss for a given data point ( x , y ) and neural network f W ( · ) is written as (cid:96) ramp ( f W ( x ) , y ) =
φ γ ( M ( f W ( x ) , y )) , where the function φ γ : R (cid:55)→ [0 , 1] is deﬁned as φ γ ( t )
= 1 if t ≤ 0 , φ γ ( t ) =
if t ≥ γ , and φ γ ( t ) = 1 − tγ if t ∈ [0 , γ ] .
Since the ramp loss is a piece-wise linear function, its surrogate loss can be directly obtained with the pairwise margin bound in Section 3.3.
The cross entropy is written as CE ( ˜ f W ( x ) , y )
= − ln
([ ˜ f W ( x )] y ) , where ˜ f W ( x ) represents a neural network with its output passing through a softmax layer.
That is, [ ˜ f W ( x )] i =
[Equation]
For ease of demonstration, we will be using ramp loss and its pairwise margin under single-layer perturbation in the following lemma.
The surrogate loss analysis for cross entropy and robust surrogate loss for multiple-layer perturbation is given in Appendix B.
Lemma 2 (robust surrogate ramp loss) Let N ∈
[ L ] denote the perturbed layer index and let
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
Then we have upper and lower bounds of ˆ (cid:96) in terms of 0-1 losses expressed as
[Equation]
[Table]
[Equation]
[Table]
Proof : Please see Appendix B.
One could observe in the formula that the margin function M ( f W ( x ) , y ) serves as an accuracy objective similar to the standard training process while the latter term could be conceived as the worst-case error caused by weight perturbation that should be suppressed.
Therefore, by training under such an objective, we can simulate the scenario of robust training.
Another intuition on the surrogate loss function is that the surrogate loss also implies the difﬁculty of training robust and generalizable models against large weight perturbations.
Since error caused by perturbations would be surging rapidly through layers, only small perturbations can be applied in training and practice, permitting the worst-case error term to be smaller than the margin term.
However, one follow-up question that naturally arises is whether or not the generalization gap will be widened when training with the robust surrogate loss.
The following section investigates the generalization property while conducting robust training and provides some theoretical insights to training toward a generalizable and robust model under weight perturbation.
3.4. G ENERALIZATION G AP FOR R OBUST S URROGATE L OSS
We consider the robust surrogate loss established in Lemma 2 and study its generalization bound via Rademacher complexity in Theorem 4, where S =
{ ( x i , y i ) } n i =1 denotes the set of i.i.d training samples, X :=
[ x 1 , x 2 , . . .
, x n ] ∈ R d × n denotes the matrix composed of training data samples, and d max = max { d, d 1 , . . .
, d L } denotes the maximum dimension among all weight matrices.
Theorem 4 (generalization gap for robust surrogate loss) With Lemma 2, consider the neural network hypothesis class F = {
[Equation]
=
[Equation]
, ..., W L ) ,
[Equation]
σ ≤
[Equation]
) T
[Equation] [Equation]
1 ≤ b h , h ∈
[ L ] } .
For any γ > 0 , with probability at least 1 − δ , we have for all f W ( · ) ∈ F
[Equation] [Equation]
[Table]
[Equation]
[Table]
Proof : Please see Appendix C.
As highlighted in the bracket term of Theorem 4, if the product of multiple weight norm bounds is not well conﬁned, the model will suffer from a notable generalization gap.
Consequently, our analysis suggests a solution to reduce the generalization gap by imposing norm penalty functions on all weight matrices for training generalizable neural networks subject to weight perturbations.
3. T HEORY - DRIVEN LOSS TOWARD ROBUSTNESS AND GENERALIZATION
With our theoretical insights, we now propose a robust and generalizable loss function.
Standard neural network classiﬁer training uses a classiﬁcation loss (cid:96) cls ( f W ( x ) , y ) that aims to widen the pairwise margin so as to raise accuracy, but won’t necessarily be able to curb the error in output once weight perturbation is imposed.
To address this issue, we propose to train under a mixed and regularized objective given a data sample ( x , y ) , which would, in turn, balance the tradeoff between standard accuracy, robustness, and generalization.
The designed loss takes the form:
[Equation]
The ﬁrst term in the proposed loss function originates from standard classiﬁcation problem for taskspeciﬁc accuracy, while the second term results from the maximum error on pairwise margin (the term η y (cid:48)
y W ( x | I ) deﬁned in Theorem 3) induced by weight perturbation.
Finally, we contribute the last term to the theoretical ﬁndings in Theorem 4, where imposing norm constraints on weight matrices could beneﬁt generalization and prevent the generalization gap from widening.
N UMERICAL V ALIDATION
We validate our theoretical results and the designed loss function in (9) through two sets of experiments: empirical generalization gap with matrix norm regularization and robust accuracy against adversarial weight perturbations .
Experiment setup We used the MNIST dataset comprised of gray-scale images of hand-written digits with ten categories.
We trained neural network models as in (3) with four dense layers (number of neurons are 128-64-32-10) and the ReLU activation function without the bias term.
We used the loss function (cid:96) ∗ in (9) with all-layer perturbation bound (i.e., I =
[ L ] ), identical weight perturbation radius (cid:15) (or (cid:15) train ), cross entropy as the standard classiﬁcation loss (cid:96) cls , and a batch size of 32 with 20 epochs.
Stochastic gradient descent with momentum is used for training, with the learning rate set to be 0.01.
For the generalization experiment, we follow the same setting as in (Yin et al., 2019), which uses 1000 data samples to train the neural network with 100 epochs.
All experiments were conducted using an Intel Xeon E5-2620v4 CPU, 125 GB RAM, and an NVIDIA TITAN
Xp GPU with 12 GB RAM.
For reproducibility, our codes are given in the supplementary material.
Empirical generalization gap Figure 1 (a) shows the empirical generalization gap (training accuracy - test accuracy) with respect to the matrix norm regularization coefﬁcient µ deﬁned in (9).
As indicated in Theorem 4, increasing µ effectively suppresses the Rademacher complexity and thus reduces the generalization gaps, which are consistently observed on neural networks trained with different weight perturbation level (cid:15) .
Robustness against adversarial weight perturbation To evaluate the robustness against weight perturbations, we modiﬁed the projected gradient descent (PGD) attack originally designed for input perturbation (Madry et al., 2018), which we call as weight PGD attack.
Starting from a trained neural network weight W , the perturbed weight (cid:102) W is crafted by iterative gradient ascent using the signed gradient of the standard loss denoted as sgn ( ∇ W (cid:96) cls ( f (cid:102) W ( x ) , y )) , followed by an element-wise (cid:15) clipping centered at W .
The attack iteration with the step size α is expressed as
[Equation]
[Equation] [Figure] as described We trained neural networks with different combinations of the coefﬁcients λ and µ in (9) using (cid:15) train = 0 .
Figure 1 (b) shows the test accuracy under different weight perturbation level (cid:15) (i.e., the robust accuracy) with 200 attack steps.
The standard model ( λ = µ = 0 ) is fragile to weight PGD attack.
On the other hand, neural networks trained only with the robustness loss ( λ > 0 and µ = 0 ) or the generalization gap regularization ( λ = 0 and µ > 0 ) can improve the robust accuracy due to improved generalization and classiﬁcation margin.
Moreover, joint training using the proposed loss with proper coefﬁcients can further boost model performance (e.g., ( λ, µ ) =
(0 . 0125 , 0 . 01) ), as seen by the signiﬁcantly improved area under curve (AUC) score of robust accuracy over all tested (cid:15) values.
The AUC of the best model is about 2 × larger than that of the standard model.
Similar results can be concluded for the attack with 100 steps (see Appendix D).
In Appendix D.3, we conduct additional experiments on the coefﬁcients λ and µ and discuss their tradeoffs.
We also report the run-time analysis in Appendix F. Training with our loss function has a comparable perepoch run time when comparing to standard training.
C ONCLUSION
In this paper, we developed a formal analysis of the robustness of the pairwise class margin for neural networks against weight perturbations.
We also characterized its generalization gap through
Rademacher complexity.
A theory-driven loss function was proposed, and the empirical results showed signiﬁcantly improved performance in generalization and robustness.
Our analysis offers theoretical insights and training loss design principles for studying the generalization and robustness of neural networks subject to weight perturbations.
A M ARGIN B OUND A. S INGLE -L AYER B OUND
We shall ﬁrst prove when N (cid:54) =
L and follow similar reasoning to prove the case when N = L
Consider the difference between set of pairwise margin f ij (cid:99) W ( x ) − f ij W ( x ) we have
[Equation]
[Equation]
[Equation]
[Equation]
where inequality (a) results from applying H¨older inequality
[Equation]
and inequality (b) comes from the contractive property (1-Lipschitz) of activation function ρ ( · ) .
Inequality (c) and (d) come from triangle inequality applied element-wise on vector W L − 1 (ˆ z L − 2 − z
L − 2 ) combined with induction while inequality (e) simply comes from the fact that every element in matrix ˆ W N − W N has at most (cid:15) in magnitude.
With similar reasoning, we proof the scenario when N =
L as following
[Equation]
19) where inequality ( i ) comes from problem deﬁnition (within element-wise (cid:96) ∞ norm ball) and since the activation function ρ ( · ) is non-negative, we could transform the inner product to its (cid:96) 1 norm.
A. M ULTI -L AYER S CENARIO A.2. K EY P REREQUISITE
Before going through the proof for all-perturbed bound, we shall be introducing a maximization problem and search for its solution.
Recall that we have deﬁned in Section 3.1 the notion of output vector under weight perturbation setting, we now consider maximizing its (cid:96) 1 norm over a given perturbed matrix set (cid:99) W and give the following solution.
Using the notation in Section 3.1, we have ˆ z k as the output vector under perturbation setting and write the optimal vector that achieve its maximum (cid:96) 1 norm as z k ∗ .
We then obtain the following solution
[Equation]
where z k ∗ =
ρ ( W k ∗ ...
ρ ( W 1 ∗ x ) with
[Equation]
The reasoning behind uses the non-negative property of activation function, for any element in a matrix W , the choice to maximize it’s
(cid:96) 1 norm matrix-vector product is to go in the direction identical to the sign of the vector’s element-wise value since the activation function is applied after the ﬁrst layer, we would then obtain the solution above.
A.2. A LL -P ERTURBED B OUND
In the following proof for Theorem 2, we apply similar steps in Appendix A.1 and consider the difference between set of pairwise margin under natural and weight perturbation setting, recall in Theorem 2 we deﬁned that f
[Equation] N ...
[Equation] ( W 1 x ) ... ) and f (cid:99) W ( x ) =
ˆ W L ( ..
[Equation]
W N ...ρ ( ˆ W
[Equation]
Thus for any set of pairwise margin f ij (cid:99) W ( x ) and f ij W ( x )
[Equation]
we have
[Equation]
[Equation]
[Equation]
[Equation]
[Equation]
In the above proof, inequality (a) comes from the problem deﬁnition (perturbation of ﬁnal layer within (cid:15) L ) and inequality (b) results from the contractive property of ρ ( · ) (1-Lipschitz) combined with the use of triangle inequality.
Inequality (c) was achieved through triangle inequality applied on elements of W L − 1 ( ˆ z L − 2 − z L − 2 ) and using the fact that ˆ W L − 1 − W L − 1 has every element less than or equal to (cid:15)
L − 1 in magnitude.
By the process of induction and maximizing the (cid:96) 1 norm of perturbed output under weight perturbation ˆ z k , we arrive at inequality (d) and (e) [Equation]
A.2. M ULTI -L AYER B OUND
We now proceed to utilize similar reasoning to establish the multi-layer bound when weight perturbation is imposed according to an index set
I
[Equation]
[Table] [Equation] [Table] [Equation]
[Table]
[Equation] [Table] [Equation] [Table]
[Equation]
[Table]
[Equation]
[Table] [Equation] [Equation] The proof for multi-layer bound follows same reasoning from the all-perturbed setting except indicator function was added to check whether a certain layer m is in the index set I and at last we rewrite the expression using the members of set I .
B S URROGATE L OSS B. C ASE ON R AMP L OSS
We now provide a proof for Lemma 2.
Recall the deﬁnition of ramp function in Section 3.4.1, we have that ramp loss for a given data point ( x , y ) and neural network f W ( · ) is written as (cid:96) ramp ( f W ( x ) , y )
=
φ γ ( M ( f W ( x ) , y )) , where the function φ γ : R (cid:55)→ [0 , 1] is deﬁned as φ γ ( t ) =
  [Equation] [Equation]
Then for any ( x , y ) , using ReLU as activation function, we have max
[Equation]
[Table]
[Equation]
[Table]
[Equation]
where inequality (a) is due to the property of ramp loss while inequality (b) is by the deﬁnition of margin and inequality (c) comes from applying Theorem 1.
Inequality (d) results from using triangle inequality and taking its maximum, inequality (e) is by the deﬁnition of margin and inequality (f) comes from the fact that with ReLU we have (cid:107) ρ ( Ax ) (cid:107) 1 ≤ (cid:107) Ax (cid:107) 1 .
Lastly, inequality (g) is a direct consequence from property of ramp loss.
B.1. R AMP L OSS ON M ULTIPLE L AYER B OUND
We now follow a similar course and prove robust ramp loss using the multi-layer bound in Theorem 3.
We consider the robust loss form proposed in Section 3.4.1 and have that,
[Equation]
[Equation] [Equation]
B. C ROSS E NTROPY
We further consider the case of cross entropy and prove an upper bound for it.
We denote the loss function as CE ( · ) , and during training, hard label was applied.
Recall the deﬁnition of ˜ f W ( x ) in
Section 3.4.1, we have the difference of loss function between natural and perturbation settings as,
[Equation]
where inequality (a) comes from taking the maximum in the set of all ratios (cid:8) e [ f (cid:99) W ( x )]
k e [ f W ( x )] k (cid:9) and inequality (b) comes from monotonicity of exponential function.
Finally, the last expression (c) can be referred to Theorem 3.
Thus with the above proof, we could establish the following robust surrogate loss for cross entropy, denoted as (cid:99) CE ( f W ( x ) , y ) :
[Equation]
C G ENERALIZATION B OUND ON R ADEMACHER C OMPLEXITY C. P ROOF ON S INGLE L AYER B OUND
To show the Rademacher complexity and generalization gap on single layer robust surrogate loss, we ﬁrst introduce a result proven in (Bartlett et al., 2017) and another classical result in statistical learning theory and proceed to give a proof on Theorem 4.
Given a set S
= { ( x i , y i ) } ni =1 of i.i.d training samples, denote X :=
[ x 1 , x 2 , . . .
, x n ] ∈ R d × n as the matrix composed of training data and let d max = max { d, d 1 , . . .
, d L } as the maximum dimension among all weight matrices.
Lemma 3 (Mohri et al.
Assume that the range of loss function (cid:96) ( · ) is [0,1].
Then, for any δ ∈ (0 , 1) , with probability as least 1 − δ , we have for all f ∈ F
[Equation]
where R ( f ) and R n ( f ) stand for population risk and empirical risk, respectively.
Lemma 4 (Bartlett et al.
Consider the neural network hypothesis class,
[Equation]
We have an upper bound on the Rademacher complexity,
[Equation]
We now study the Rademacher Complexity of the function class
[Equation]
where ˆ (cid:96) ( · ) is denoted in Lemma 2 and let M F = { ( x , y )
(cid:55)→ M ( f W ( x ) , y )
| f ∈ F} .
Then we could obtain,
[Equation]
where the inequality was achieved by using the Ledoux-Talagrand contraction inequality and the convexity of the supreme operation.
Consider the second term
[Equation]
we have that
[Equation]
where inequality (a) is achieved by separating all neural network related parameters and inequality (b) is a result of applying Khintchine’s inequality.
Thus
[Equation]
combined with Lemma
[Equation]
we have that
[Equation]
Once we have calculated an upper bound for R (ˆ (cid:96) F )
[Equation]
then Theorem 4 is a direct consequence of
Lemma 2 and 3.
C. E XTENSION TO M ULTIPLE L AYER B OUND
In this section
[Equation]
we consider the robust surrogate loss under multi-layer bound and study its
Rademacher complexity, We ﬁrst give the expression of the robust surrogate loss then give an result on generalization bound
[Equation]
Lemma 5 Deﬁne the robust loss function ˆ (cid:96) ( f W ( x ) , y ) as
[Equation]
W
[Equation]
x
[Equation]
, y )
[Equation]
We would have that max
[Equation]
[Table]
γ (cid:19)
Using the above loss
[Table]
we could further establish an upper bound on robust surrogate loss and provide statements on generalization bound.
Given the following function class
[Table]
We have that,
[Table]
56) which the second term can be bounded as,
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
while the last term can as well be bounded as,
[Equation]
[Table]
[Equation]
With all of the upper bounds above and Lemma 4, 5, we have the following theorem,
Theorem 5 (generalization gap for robust surrogate loss) With Lemma 5, consider the neural network hypothesis class F = { f W ( x ) | W
=
( W 1 , W 2 , ..., W L ) , (cid:13)(cid:13)
W h
[Equation]
σ ≤ s
[Equation]
( W h ) T (cid:13)(cid:13) 2 , 1 ≤ b h , h ∈
[ L ] } .
For any γ > 0 , with probability at least 1 − δ , we have for all f W ( · ) ∈ F
P
[Equation]
x
[Equation]
y
[Equation]
∼
[Equation] [Equation]
[Table]
2 n
[Equation] [Equation]
D A DDITIONAL E XPERIMENTS D. S UPPLEMENT OF F IGURE 1 ( A )
For completeness, Figure 2 adds the curve of (cid:15) =
(the standard generalization setting) in Figure(a).
The generalization gap is obviously lower than others when (cid:15) = 0, but its trend with respect to regularization is similar to the setting when (cid:15) (cid:54) = 0 .
D. WEIGHT PGD ATTACK (100 STEPS ) ON MNIST
Figure 3 shows the accuracy and AUC score of different models against weight PGD attack with 100 iterations.
D. M ORE DETAILS ON THE TRADE - OFF BETWEEN λ AND µ
[Figure]
Figure 4 shows the trade-off with a ﬁne grid search between coefﬁcients λ and µ , we present test accuracy under weight PGD attack using perturbation radius of ( (cid:15) = 0 .
01 and 0 .
with different combinations of λ (from 0.01 to 0.015) and µ (from 0 to 0.05).
We ﬁnd that there is indeed a sweet spot with proper values of λ and µ leading to signiﬁcantly better robust accuracy.
When both λ and µ are too large or too small, the robustness of the model will decrease.
E O N THE VACUITY OF GENERALIZATION BOUND
In (Nagarajan & Kolter, 2019), empirical observations were made to point out the fact that when given increase in the size of the training data, the error bound proposed in (Bartlett et al., 2017) grows rapidly, loosing the ability to describe generalization gap and thus becomes vacuous.
However, we note that under our settings with models trained using the loss function in Section 3.5, the bound would not grow in a polynomial rate and instead shows a decreasing trend.
We conducted experiments and presented results under the same setting as (Nagarajan & Kolter, 2019) in Figure 5.
Here we verify two existing generalization bounds from different literature, one from (Bartlett et al., 2017) while another one from (Barron & Klusowski, 2018) in which the former one is composed mainly of product of weight matrices’ norm and the latter is comprised of the norm of matrices’ product.
Empirical results in Figure 5(a) show that under the standard settings the main components of generalization bound in (Bartlett et al., 2017) and Barron & Klusowski (2018) both grows rapidly with respect to the increase in size of the training dataset, as conﬁrmed in (Nagarajan & Kolter, 2019).
Another empirical ﬁnding in the last column of Figure 5(a) shows that the multiplicative difference between bounds in (Bartlett et al., 2017) and (Barron & Klusowski, 2018) exhibit a constant rate, demonstrating the vacuity of both bounds.
However, when measuring the same component under our setting in Figure 5(b), new results showed decreasing bounds as the size of the training dataset increases, concluding the non-vacuity of the associated generalization bounds in our settings.
[Figure]
As an ablation study, Figure 6 shows the performance of the robust model with ( λ = 0 . 01 , µ = 0 ).
That is, training a neural network without the generalization regularization term in equation (9).
Unlike the standard model, it is observed that the generalization bounds still show decreasing trend with the test error.
This is due to the fact that the robustness term in equation (9), which is induced from our analysis of the worst-case error propagation from weight perturbation, also plays a role in regularizing the network weights, and therefore making the resulting generalization bound nonvacuous.
F R UN T IME A NALYSIS
Table 1 reports the per-epoch run time of the models trained with the standard model ( λ = 0 , µ = 0) and the robust model ( λ = 0 .
01 , µ = 0 .
1) using equation (9).
We train both models with 20 epochs and use the same hyperparameters, including setting the SGD optimizer with learning rate as 0.01, and setting the batch size as 32.
The cost of training both models are comparable.
[Table]