Formalizing Generalization and Adversarial Robustness of Neural Networks to Weight Perturbations

Abstract:
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 first integral study and analysis for feed-forward neural networks in terms of the robustness in pairwise class margin and its generalization behavior under weight perturbation. 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.

heading: 1 Introduction
text: 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, feedforward 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 quantization is crucial for designing energy-efficient hardware accelerator [20] and for reducing memory storage while retaining model performance [9, 26]. The notion of weight perturbation sensitivity is also used as a property to reflect the generalization gap at local minima [10, 15]. In adversarial robustness and security, weight sensitivity can be leveraged as a vulnerability for fault injection and causing erroneous prediction [11, 32]. 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 classification margin) of neural networks against norm-bounded weight perturbations. Specifically, we consider
1Work partly done in TCFSH
35th Conference on Neural Information Processing Systems (NeurIPS 2021).
the multi-class classification 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 first work that provides a comprehensive theoretical characterization of the interplay between weight perturbation, robustness in classification 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. Our main contributions are summarized 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. We also show that in our studied setting the associated generalization bounds are non-vacuous.

heading: 2 Related Works

heading: 2.1 Generalization in Standard Settings
text: In model compression, the robustness to weight quantization is critical to reducing memory size and accesses for low-precision inference and training [9]. [20] showed that neural models that are robust to random bit flipping errors are beneficial for operating in low-voltage regime and thus improving energy efficiency for hardware implementation. [26] showed that incorporating weight perturbation sensitivity into training can better retain model performance (standard accuracy) after quantization. For studying the generalization of neural networks, [10] 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. Similar concepts of considering nearby parameter loss is as well presented in [18] where this concept is to circumvent from falling into sharp empirical loss pit with high generalization gap. [1] introduced weight noise into the training process and concluded that random noise training improves the overall generalization. [27] empirically showed that using adversarial weight perturbation during training can improve generalization against input perturbations. [5] obtained non-vacuous generalization bound on deep (stochastic) neural networks by directly optimizing the PAC-Bayes bound while [16] as well combined weight perturbation with PAC-Bayes analysis to derive the generalization bound. [15] 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, [4] 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, [7] incorporated additional assumptions to offer tighter and size-independent bounds from the setting of [17] and [4] respectively. We note that previous methods use random weight perturbations to evaluate the generalization ability (e.g. sharpness), which we call a standard generalization setting. In contrast, we study a different problem setup: generalization of models trained under worst-case (adversarial) weight perturbation.
Despite development of various generalization bounds, empirical observations in [14] showed that once the size of the training dataset grows, generalization bounds proposed in [15] and [4] will enlarge and thus become vacuous. Discussions on the relation between [14] 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, [3] and [22] 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 [19] 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. [26] proposed a certification method for weight perturbation retaining consistent model prediction. While the certification bound can be used to train robust models with interval bound propagation [8], it requires additional optimization subroutine and computation costs when comparing to our approach. Moreover, the convoluted nature of certification bound complicates the analysis when studying generalization, whereas our theoretical characterization is an intuitive and tight worst-case analysis.

heading: 2.2 Adversarial Robustness and Input/Weight Perturbation
text: In adversarial robustness, fault-injection attacks are known to inject errors to model weights at the inference phase and causing erroneous model prediction [11, 32], which can be realized at the hardware level by changing or flipping the logic values of the corresponding bits and thus modifying the model parameters saved in memory [2, 24]. [31] 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 — input perturbations. Both empirical and theoretical evidence suggests the existence of a fundamental trade-off between generalization and robustness against norm-bounded input perturbations [28, 21, 30, 23]. The adversarial training proposed in [12] is a popular training strategy for training robust models against input perturbations, where a minmax 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, [25] proved its convergence and [29] 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 quantifiable metrics for training generalizable and robust neural networks against weight perturbations.

heading: 2.3 Comparison against Related Generalization Bound
text: In the following subsection below we will provide the discussion to our characterization of generalization bound against similar notions in other related works. For the convenience of comparison, we formulated it as a table in Appendix H. In what follows we offer the detailed comparison on different settings, equation setup between ours and these related notions.
In [6], the authors extended the result of sharpness [15] and integrated this concept as a part of the training process, namely the sharpness-aware minimization. In the paper, the author instead of directly solving the inner maximization loop, uses linear approximation to resolve the issue. Furthermore, the generalization bound given in [6] considers only the standard setting, in which the generalization gap is measured between population risk and the sharpness-aware sample risk, differing from our adversarial setting where the generalization gap is contrast between both adversarial population and sample risk.
On the other hand, the authors in [27] propose to utilize weight perturbation to mitigate the widening robust generalization gap (based on input robustness). In [27], the author trains the model by injecting the so-called “double perturbation” into the training process. We note that this is different from our approach of constructing adversarial robustness on weight space. Specifically, the weight perturbation in [27] (second maximization step in equation (7), [27]) is determined after every corresponding adversarial example is calculated, while our approach focuses on the worst-case weight perturbation given every sample data. Moreover, the generalization gap extends from [15] where it is measured against the population risk and the sample risk along with perturbation direction sampled from zero mean spherical Gaussian distribution. On the contrary, our setting considers a generalization gap from both the adversarial population risk and sample risk.

heading: 3 Main Results
text: We provide an overview of the presentation flow 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 simplified 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. Here we would like to note that similar reasoning could be applied to obtain results in convolutional neural networks and we relay the corresponding results and experiments in Appendix A.4, respectively. In Section 3.4, we define 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.

heading: 3.1 Notation and Preliminaries
text: Notation We start by introducing the mathematical notations used in this paper. We define the set [L] := {1, 2, ..., L}. For any two non-empty sets A, B, FA 7→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 ∈ Rk×d , we write its i-th row, j-th column and (i, j) element as Wi,:, W:,j , and Wi,j respectively. Moreover, we write its transpose matrix as (W)T . The matrix (p, q) norm is defined as ‖W‖p,q := ∥∥∥[‖W:,1‖p , ‖W:,2‖p , ..., ‖W:,d‖p]∥∥∥ q
for any p, q ≥ 1. For convenience, we have ‖W‖p = ‖W‖p,p and write the spectral norm and Frobenius norm as ‖W‖σ and ‖W‖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 ‖W‖1,∞, which is defined as ‖W‖1,∞ = maxj ‖W:,j‖1 and ∥∥WT∥∥ 1,∞ = maxi ‖Wi,:‖1. We use IB ∞ W ( ) to express an element-wise `∞ norm ball of matrix W within radius , i.e., IB∞W ( ) = {Ŵ| |Ŵi,j −Wi,j | ≤ ,∀i ∈ [k], j ∈ [d]}.
Preliminaries In order to formally explain our theoretical results, we introduce the considered learning problem, neural network model, and complexity definition. 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 specifically consider the feature space X as a subset of d-dimensional Euclidean space, i.e., X ⊆ Rd. We denote the symbol F ⊆ FX 7→Y to be the hypothesis class which we use to make predictions. Furthermore, we consider a loss function ` : X × Y −→ [0, 1] and compose it with the hypothesis class to make a function family written as `F := {(x, y) 7→ `(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[`(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 {(xi, yi)}ni=1, which can be expressed as Rn(f) = 1n ∑n i=1 `(f(xi), yi). 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 [13]. The empirical Rademacher complexity of a function class F given a set of samples S = {(xi, yi)}ni=1 is RS(`F ) = Eν [supf∈F 1n ∑n i=1 νi`(f(xi), yi)] 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 following relationship between generalization error and complexity measure. Specifically, it is shown in [13] that given a set of training samples S and assume that the range of loss function `(f(x), y) is [0, 1]. Then for any δ ∈ (0, 1), with at least
probability 1 − δ we have ∀f ∈ F , R(f) ≤ Rn(f) + 2RS(`F ) + 3 √ log 2δ 2n 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 define the structure of neural networks and introduce a few related quantities. The problem studied in this paper is a multi-class classification task with the number of classes being K. Consider an input vector x ∈ X ⊆ Rd, an L-layer neural network is defined as fW (x) = WL(...ρ(W1x)...) ∈ FX 7→R with W being the set containing all weight matrices, i.e., W := {Wk| ∀k ∈ [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 elementwise on a vector. Moreover, the i-th component of neural networks’ output is written as f iW (x) = [fW (x)]i and a pairwise margin between i-th and j-th class, denoted as f ijW (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 zk 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 zk = ρ(Wk(...ρ(W1x)...)) and ẑk = ρ(Ŵ k (...ρ(Ŵ 1 x)...)), where Ŵ i ∈ IB∞Wi( i) denotes the perturbed weight matrix bounded by its element-wise `∞-norm with radius i for some i ∈ [k]. Throughout this paper, we study the weight perturbation setting that each layer has an independent layer-wise perturbation budget, denoted by k, ∀k ∈ [L]. In the case of single-layer perturbation, we may omit the layer index and simply use .

heading: 3.2 Building Block: Single-Layer Weight Perturbation
text: We study the sensitivity of neural network to weight perturbations through the pairwise margin bound f ijW (x). Specifically, 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 have provided a simple example of a three-layer neural network and explain the bound through the error propagation incurred by weight perturbation in Appendix A.1. Here we directly introduce and analyze our theorem below.
Theorem 1 (N -th layer weight perturbation (N 6= L)) Let fW (x) = WL(...ρ(W1x)...) denote an L-layer neural network and let f
Ŵ (x) = WL(..Ŵ
N ...ρ(W1x)...) with Ŵ N ∈ IB∞WN ( N ), N 6= L, denote the corresponding network subject to N -th layer perturbation. For any set of perturbed and unperturbed pairwise margin f ij
Ŵ (x) and f ijW (x), we have
f ij Ŵ (x) ≤ f ijW (x) + N ∥∥WLi,: −WLj,:∥∥1 ∥∥zN−1∥∥1 ΠL−N−1k=1 ∥∥(WL−k)T∥∥1,∞
:= f ijW (x) + ∆( N ; z N−1; f)
where zk = ρ(Wk(...ρ(W1x)...)).
Proof : See Appendix A.2
Since the final layer does not have any activation function, the margin bound on the margin difference when only perturbing the final 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 Ŵ (x) ≤ f ijW (x) + 2 L ∥∥zL−1∥∥ 1
where zL−1 is the output of the (L− 1)-th layer.
Proof : See Appendix A.2.

heading: 3.3 General Setting: Multi-Layer Weight Perturbation
text: 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.

heading: 3.3.1 Perturbing All Layers
text: 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.
For simplicity and understanding, we will introduce an notation previously used but not fully explained in Theorem 1 and Lemma 1. Specifically, the notion ∆(·) can be described as the error caused by certain layer. Moreover, as we will see later, the function requires three inputs, the perturbation of that certain layer, the previous input and finally the neural network. Explicitly, for an L-layer neural network f(·), a perturbation radius of the k-th layer k, and a prior input z, the delta function can be described as the following,
∆( k; z; f) = k ∥∥WLi,: −WLj,:∥∥1‖z‖1(ΠL−1m=k+1 ‖Wm‖1,∞)
We denote the model under this case 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 fW (x) = WL(...ρ(W1x)...) denote an L-layer (natural) neural network and let f
Ŵ (x) = Ŵ
L (..Ŵ N ...ρ(Ŵ 1 x)...) with Ŵ k ∈ IB∞Wk( k), ∀k ∈ [L], denote its perturbed version. For any set of pairwise margin f ij
Ŵ (x) and f ijW (x), we have
f ij Ŵ (x) ≤ f ijW (x) + ∆( 1; x; f)︸ ︷︷ ︸ Input Layer Error + L−1∑ k=2 ∆( k; zk−1 ∗ ; f)︸ ︷︷ ︸
Intermediate Layer Error
+ 2 L ∥∥∥zL−1∗∥∥∥ 1︸ ︷︷ ︸
Final Layer Error
where zk ∗ = ρ(Wk ∗ ...ρ(W1 ∗ x) with Wk ∗ defined as{
W k ∗
i,j = W k i,j + k, ∀i, j and ∀k ∈ [L] \ {1}
W 1 ∗
i,j = W 1 i,j + sgn([x]j) 1, ∀i, j
Proof : See Appendix A.3.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. Specifically, we can choose any perturbed layer as the commencement point of propagation, then fix 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 final 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 first term since the input layer and the rest of the terms are errors propagating since the k-th layer in the neural network, where k ∈ [L].

heading: 3.3.2 Perturbing Multiple Layers
text: 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 (I = {N}) and all-perturbed (I = [L]) settings as special cases.
Theorem 3 (multiple-layer perturbation) Let fW (x) = WL(...ρ(W1x)...) denote an L-Layer neural network. Given an index set I ⊆ [L], we define the perturbed neural network as
f Ŵ
(x) = W̃ L (...W̃ N ...ρ(W̃ 1 x)...) with
{ W̃ k
= Wk, ∀k ∈ [L] \ I W̃ k = Ŵ k , Ŵ
k ∈ IB∞Wk( k),∀k ∈ I
Then, for any pairwise margin between f ij Ŵ (x) and f ijW (x),
f ij Ŵ (x) ≤ f ijW (x) + ∑
k∈I\{L}
∆( k; zk−1 ∗ ; f)
︸ ︷︷ ︸ Perturbed Layer Error
+ 1(L ∈ I)2 L ∥∥∥zL−1∗∥∥∥
1︸ ︷︷ ︸ Final Layer Error
:= f ijW (x) + η ij W (x|I)︸ ︷︷ ︸
Error of Weight Perturbation
where zk ∗ = ρ(Wk ∗ ...ρ(W1 ∗ x) with Wk ∗ defined as  W k ∗ i,j = W k i,j + k, ∀i, j ∀k ∈ [L] ∩ I \ {1} W ki,j , ∀i, j ∀k ∈ [L] \ (I ∪ {1}) W 1 ∗ i,j = { W 1i,j + sgn([x]j) 1, ∀i, j if 1 ∈ I W 1i,j , ∀i, j otherwise and z0 ∗ = x.
Proof : See Appendix A.3.3.

heading: 3.4 Surrogate Loss and Generalization Bound

heading: 3.4.1 Construction of Robust Surrogate Loss on Pairwise Margin
text: We aim to construct a surrogate loss function based on a standard loss function and study its behavior against weight perturbations. Here we study the single-layer perturbation case and elucidate the multi-layer perturbation case in Appendix B. Specifically, given a perturbation budget for the k-th layer and the original loss function `(fW(x), y), robust training aims to minimize the following objective function: ˜̀(fW (x), y) = maxŴm∈IB∞Wm ( ) `(fŴ (x), y), 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 constructing a surrogate loss by means of pairwise margin bounds in Section 3.3. We first define two popular loss functions in the classification problem, ramp loss and cross entropy, and derive their surrogate versions. Define the margin function M(fW (x), y) as
M(fW (x), y) = min y′ 6=y [fW (x)]y − [fW (x)]y′ = [fW (x)]y −max y′ 6=y [fW (x)]y′ (1)
The ramp loss for a given data point (x, y) and neural network fW (·) is written as `ramp(fW (x), y) = φγ(M(fW (x), y)), where the function φγ : R 7→ [0, 1] is defined as φγ(t) = 1 if t ≤ 0, φγ(t) = 0 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 = exp
[fW (x)]i∑ k∈[K] exp [fW (x)]k . 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
Ψ(fW (x)) = 2 max k∈[K] N ∥∥WLk,:∥∥1 ΠN−1m=1 ‖Wm‖1,∞ΠL−N−1k=1 ∥∥(WL−k)T∥∥1,∞ ‖x‖1
be the worst case error and ˆ̀(fW (x), y) := φγ { M(fW (x), y)︸ ︷︷ ︸
margin
− Ψ(fW (x))︸ ︷︷ ︸ worst-case error } Then we have upper and lower bounds of ˆ̀ in terms of 0-1 losses expressed as
max ŴN∈IB∞
WN ( )
1{y 6= arg max y′∈[K] [fŴ (x)]y′} ≤ ˆ̀(fW (x), y) ≤ 1{M(fW (x), y)−Ψ(fW (x)) ≤ γ}.
Proof : Please see Appendix B.1
One could observe in the formula that the margin function M(fW (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 difficulty 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.

heading: 3.4.2 Generalization Gap for Robust Surrogate Loss
text: We consider the robust surrogate loss established in Lemma 2 and study its generalization bound via Rademacher complexity in Theorem 4, where S = {(xi, yi)}ni=1 denotes the set of i.i.d training samples, X := [x1, x2, . . . , xn] ∈ Rd×n denotes the matrix composed of training data samples, and dmax = max{d, d1, . . . , dL} denotes the maximum dimension among all weight matrices. Firstly, we define the adversarial population risk and empirical risk as
R(f) = P(x,y)∼D { ∃ŴN ∈ IB∞WN ( ) s.t. y 6= arg max
y ′∈[K]
[fŴ(x)]y′ }
Rn(f)= 1
n n∑ i=1 1 ( [fW (xi)]yi≤ γ+ max y ′ 6=yi [fW (xi)]y′+Ψ(fW (x)) )
Secondly, we denote the following empirical Rademacher complexity of both margin function and worst-case error as
RS(MF ) = 4n3/2 + 60 log(n) log(2dmax) n ‖X‖F ( ΠLh=1sh )(∑L j=1 ( bj sj )2/3)3/2
RS(ΨF ) = 2 N supf∈F Π
N−1 m=1‖W m‖1,∞Π L−N−1 k=0 ‖(WL−k)T‖1,∞
n ‖X‖1,2
Theorem 4 (generalization gap for robust surrogate loss) With Lemma 2, consider the neural network hypothesis class F̂ = {f
Ŵ (x)|W = (W1, ...ŴN , ...,WL), ŴN ∈ IB∞WN( N) ∥∥Wh∥∥ σ ≤
sh, ∥∥(Wh)T∥∥
2,1 ≤ bh,h ∈ [L]}. For any γ > 0, with probability at least 1 − δ, we have for
all fW (·) ∈ F
R(f) ≤ Rn(f) + 1 γ ( RS(MF )︸ ︷︷ ︸
standard generalization gap + RS(ΨF )︸ ︷︷ ︸ complexity term of robust training ) + 3
√ log 2
δ
2n
Proof : Please see Appendix C.1
As highlighted in the bracket term of Theorem 4, if the product of multiple weight norm bounds in the additional complexity termRS(ΨF ) caused by robust training is not well confined, the model can 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.

heading: 3.5 Theory-driven Loss toward Robustness and Generalization
text: With our theoretical insights, we now propose a robust and generalizable loss function. Standard neural network classifier training uses a classification loss `cls(fW (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:
`∗(fW (x), y) = `cls(fW (x), y)︸ ︷︷ ︸ standard loss + λ · max y′ 6=y {ηy ′y W (x|I)}︸ ︷︷ ︸ robustness loss from Thm. 3
+ µ · L∑
m=1
( ∥∥∥(Wm)T∥∥∥ 1,∞ + ‖Wm‖1,∞ )
︸ ︷︷ ︸ generalization gap regularization from Thm. 4
(2)
The first term in (2) originates from standard classification problem for task-specific accuracy, while the second term results from the maximum error on pairwise margin (the term ηy
′y W (x|I)
defined in Theorem 3) induced by weight perturbation. Finally, we contribute the last term to the theoretical findings in Theorem 4, where imposing norm constraints on weight matrices could benefit generalization and prevent the generalization gap from widening. Based on our analysis, we also note that the standard technique of L1 penalty function on weight applies as well.

heading: 4 Numerical Validation
text: We validate our theoretical results and the designed loss function in (2) 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 (Section 3.1) 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 `∗ in (2) with all-layer perturbation bound (i.e., I = [L]), identical weight perturbation radius (or train), cross entropy as the standard classification loss `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 [29], which uses 1000 data samples to train the neural network. In all settings we assign identical weight perturbation budget for every layer. The comparison of weight distribution of each layer using standard and our proposed robust training is given in Appendix F. 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.
Weight PGD attack To evaluate the robustness against weight perturbations, we modified the projected gradient descent (PGD) attack originally designed for input perturbation [12], which we call as weight PGD attack. Starting from a trained neural network weight W , the perturbed weight W̃ is crafted by iterative gradient ascent using the signed gradient of the standard loss denoted as sgn(∇W `cls(fW̃ (x), y)), followed by an element-wise (or test) clipping centered at W . The attack iteration with the step size α is expressed as
W̃ (0) = W , W̃ (t+1) = ClipW , { W̃ (t) + α sgn(∇W `cls(fW̃ (t)(x), y)) } (3)
Empirical generalization gap Figure 1 (a) shows the empirical generalization gap (training accuracy - test accuracy) with respect to the matrix norm regularization coefficient µ under 200-step weight PGD attack with the perturbation level test defined in (2) and we supplement test accuracies in Appendix D.2. 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 train. We also conduct different settings of generalization gap analysis with test = 0 and different train values in Appendix D.1. To demonstrate the necessity of our regularization loss function, in Appendix D.3, we run the same experiments of Figure 1 (a) but replace our regularization loss with L1 and L2 weight decay, respectively. It shows that only our loss function can aid reducing generalization gap and improving robustness.
Robust accuracy against adversarial weight perturbation We trained neural networks with different combinations of the coefficients λ and µ in (2) using train = 0.01. Figure 1 (b) shows the test accuracy under different weight perturbation level test (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 classification margin. Moreover, joint training using the proposed loss with proper coefficients can further boost model performance (e.g., (λ, µ) = (0.0125, 0.045)), as seen by the significantly improved area under curve (AUC) score of robust accuracy over all tested test 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.5). Appendix D.4 shows additional experiments on the extension to convolutional neural networks trained on CIFAR-10. Similar conclusion holds. In Appendix D.6, we conduct additional experiments on the coefficients λ and µ and discuss their tradeoffs. In summary, the results suggest the effectiveness of our theory-driven loss function for improving generalization against weight perturbation.
Run-time analysis and weight quantization The run-time analysis in Appendix D.8 shows the training costs for robust and standard models are comparable. In Appendix D.9, we also show that neural networks trained with our proposed loss are more robust to weight quantization. Under 2-bit quantization, the decrease in accuracy of the robust model is 3x less than the standard model.
Non-vacuous generalization bound under weight perturbation In the standard generalization setting, [14] showed that when increasing the size of the training data, the error bound in [4] grows rapidly, loosing the ability to describe generalization gap and thus becomes vacuous. In Appendix 3.5, we show that the error bounds of the models trained using our proposed loss function (2) in Section 3.5 would not grow in a polynomial rate and instead shows a decreasing trend, concluding the non-vacuity of the associated generalization bounds in our robust generalization setting.
Comparison to naive adversarial weight training (AWT) We also present comparisons of test accuracy between models trained with AWT, our loss, and the standard model under weight PGD attack with different perturbation level test in Appendix G. It shows that directly applying weight PGD attack into adversarial training is not effective in training robust models.

heading: 5 Conclusion
text: In this paper, we developed a formal analysis of the robustness associated with the pairwise class margin for neural networks against weight perturbations. We also characterized its generalization gap through Rademacher complexity. A theory-driven loss function for robust generalization was proposed, and the empirical results showed significantly improved performance in generalization and robustness. Our analysis offers theoretical insights and informs the principles of training loss design toward generalizable and robust neural networks subject to weight perturbations.

heading: Acknowledgments
text: Part of this work was done during Chia-Yi Hsu’s visit at IBM Research. Yu-Lin Tsai, Chia-Yi Hsu and Chia-Mu Yu were supported by MOST 110-2636-E-009-018 and we also thank to National Center for High-performance Computing (NCHC) of National Applied Research Laboratories (NARLabs) in Taiwan for providing computational and storage resources.

Review summaries:
In this paper, the authors developed a formal analysis of the robustness associated with the pairwise class margin for neural networks against weight perturbations. The authors also characterized its generalization gap through Rademacher complexity and proposed a theory-driven loss function for robust generalization. The empirical results showed significantly improved performance in generalization and robustness.  

The paper studies the worst-case perturbations in the weight-space for multi-layer networks. The authors first derive a robust surrogate loss which is an upper bound on the loss under norm-bounded weight perturbations based on a product of the 1-inf matrix norm of layer weight matrices. Then the authors derive a generalization bound based on the Rademacher complexity which motivates their new loss function which is evaluated empirically on MNIST.

The paper studies the effect of weight perturbations in a neural network on its performance in terms of generalization and adversarial robustness. Robustness to weight perturbations is important for improving a model’s fault tolerance and reducing its storage requirements without significantly compromising its performance. It uses Rademacher complexity to quantify the impact on generalization and pairwise class margins for adversarial robustness. It considers networks with non-negative monotone activation functions that are 1-Lipschitz. Using the theory developed in the paper, the authors propose a new loss function for training more generalizable and robust models.