Skip to content

Formally analyzing the generalization and robustness of neural networks to weight perturbationsFormalizing Generalization and Robustness of Neural Networks to Weight Perturbations

arXiv· arXiv:2103.02200· Yu-Lin Tsai, Chia-Yi Hsu, Chia-Mu Yu, Pin-Yu ChenNational Yang Ming Chiao Tung University; IBM ResearchIndexed by this site · 27 days ago· Originally publishedAttacks

Quick read

Defenses

Based on the paper PDF (AI-generated); refer to the original

The authors theoretically characterize the inter-class margin robustness and generalization gap of feedforward neural networks under weight perturbations, propose a theory-driven training loss, and validate it on MNIST.

Questions
Weight perturbations (quantization, fault injection attacks, etc.) affect the generalization and robustness of neural networks, but the authors state that previously there was a lack of theoretical characterization of their generalization gap and inter-class margin robustness.
Methods
The authors derive worst-case upper bounds on the pairwise class margin for single-layer, all-layer and selected-layer weight perturbations respectively, use Rademacher complexity to characterize the generalization gap of the robust surrogate loss, and on this basis design a training loss containing a robust term and a norm regularization term.
Experiments and results
Evaluated on MNIST with a weight PGD attack: the authors state that increasing the regularization coefficient µ can reduce the generalization gap; joint training (e.g., λ=0.0125, µ=0.045) improves robust accuracy, and the AUC of the best model is about 2 times that of the standard model; under 2-bit quantization, the accuracy of the robust model drops by 28.71%, and that of the standard model drops by 85.14%.
Limitations and future work
The paper does not specifically discuss limitations (in the Checklist the authors state that the proposed loss can in theory be used without restriction for more applications). Experiments are limited to a 4-layer fully connected network on MNIST and a small convolutional network on CIFAR-10; repeated experiments with random seeds and error bars are not reported, and the code must be requested.
Experimental setupfour-layer dense neural network (128-64-32-10) trained with the proposed loss、convolutional neural networks trained on CIFAR-10 · MNIST、CIFAR-10 · test accuracy under weight PGD attack、empirical generalization gap et al.
Threat model
At inference time, the attacker applies to the model weights a perturbation within an element-wise l∞ norm ball (an independent budget εk per layer), which may be a single layer, selected multiple layers, or all layers; the paper evaluates robustness with a weight PGD attack (200 or 100 steps, step size α, signed gradient ascent with ε clipping), and the victim system is an L-layer feedforward neural network classifier.
Evaluated models
four-layer dense neural network (128-64-32-10) trained with the proposed lossconvolutional neural networks trained on CIFAR-10
Benchmarks
MNISTCIFAR-10
Metrics
test accuracy under weight PGD attackempirical generalization gapAUCper-epoch run time
AI summaryThe authors state that this is the first complete study of the pairwise class-margin robustness and generalization behavior of feedforward neural networks under weight perturbations, and they design a theory-driven new loss function for training neural networks with generalization and robustness to weight perturbations. Experiments validate the theoretical analysis, and the study has reference value for tasks such as model compression, generalization gap evaluation, and adversarial attacks.

The authors state that this is the first complete study of the pairwise class-margin robustness and generalization behavior of feedforward neural networks under weight perturbations, and they design a theory-driven new loss function for training neural networks with generalization and robustness to weight perturbations. Experiments validate the theoretical analysis, and the study has reference value for tasks such as model compression, generalization gap evaluation, and adversarial attacks.

Paper analysis

6 questions; open one to read the full answer

  1. What problem does this paper attempt to solve?

    The authors aim to characterize the impact of weight perturbations on the generalization gap and inter-class margin robustness of neural networks, and to provide a theory-driven training loss.

    Core problem: the generalization and robustness of neural networks under weight perturbations lack a theoretical characterization; how to analyze and train models that both generalize well and are robust to weight perturbations.

    • Problem setting: the authors point out that sensitivity to weight perturbations is relevant to model compression (weight quantization, low-precision inference), generalization gap evaluation (sharpness), and security (fault injection attacks can flip weight bits at inference time to cause misclassification).
    • Existing gaps: the authors state that prior work mostly evaluates generalization using random weight perturbations (the standard setting), and that a theoretical characterization of generalization and robustness under worst-case (adversarial) weight perturbations is still lacking; the certification method of [26] requires an additional optimization subroutine and is unfavorable for generalization analysis.
    • Core observation: the authors point out that min-max training for weight perturbations is not directly feasible, because both the minimization and the maximization act on the model parameters; the authors resolve this form by deriving a computable upper bound for the inner maximization.
    • Contributions: the authors give worst-case upper bounds on the pairwise class margin under single-layer (Theorem 1), all-layer (Theorem 2), and selected multi-layer (Theorem 3) perturbations, give a generalization bound for the robust surrogate loss using Rademacher complexity (Theorem 4), and propose a theory-driven loss function (Equation (2)). The authors claim this is the first work to comprehensively characterize the relationship among weight perturbations, margin robustness, and the generalization gap.
    • Threat model:
      • Attacker goal: perturb the model weights at inference time to cause misclassification (fault injection scenario).
      • Knowledge: the paper does not explicitly define the attacker's level of knowledge; the weight PGD attack uses gradients of the model weights.
      • Capability: apply to the weights a perturbation within an element-wise l∞ norm ball, with an independent budget εk per layer; may perturb a single layer, selected multiple layers, or all layers.
      • Victim system: an L-layer feedforward neural network multiclass classifier (the appendix extends to convolutional networks).
  2. What related research exists?

    Related work falls into three groups: research on generalization under the standard setting, adversarial robustness under input/weight perturbations, and the two generalization-bound settings that the authors compare separately.

    Generalization under the standard setting

    • Keskar et al. [10] proposed the sharpness (weight sensitivity) metric to evaluate the generalization of local minima; Neyshabur et al. [15] connected sharpness with PAC-Bayes; Bartlett et al. [4] proposed a spectral-normalized margin bound. The authors point out that these all belong to the standard generalization setting under random weight perturbations, whereas this paper studies generalization under worst-case weight perturbations.
    • Dziugaite & Roy [5] directly optimized the PAC-Bayes bound to obtain a non-vacuous generalization bound; Nagarajan & Kolter [14] pointed out that the bounds of [15] and [4] become vacuous as the training set grows. The authors state in Appendix E that the corresponding bounds under this paper's setting are non-vacuous.
    • Weng et al. [26] proposed a certification method for weight perturbations; the authors point out that it requires an additional optimization subroutine and computational cost, and that the certified bound is unfavorable for generalization analysis, whereas this paper is an intuitive worst-case analysis.

    Adversarial robustness and input/weight perturbations

    • Liu et al. [11] and Zhao et al. [32] studied fault injection attacks, flipping weight bits at inference time to cause misclassification; Zhao et al. [31] used mode connectivity of the loss landscape to mitigate such attacks.
    • Madry et al. [12] proposed adversarial training against input perturbations (min-max); Yin et al. [29] gave a Rademacher complexity bound for adversarial training against input perturbations. The authors point out that min-max for weight perturbations is not directly feasible, because both optimization steps act on the parameters.
    • Several works [28, 21, 30, 23] discuss the trade-off between generalization and robustness under input perturbations.

    Two works the authors compare separately

    • Foret et al. [6] (Sharpness-Aware Minimization, 2021): solves the inner maximization using a first-order approximation; the authors point out that its generalization bound is in the standard setting (population risk versus sharpness-aware sample risk), whereas this paper is adversarial population risk versus adversarial sample risk.
    • Wu et al. [27] (Adversarial Weight Perturbation, 2020): injects "double perturbation" during training; the authors point out that its weight perturbation is determined only after each adversarial sample is computed, whereas this paper takes the worst-case weight perturbation for each sample, and the definition of the generalization gap differs (Table 7 in Appendix H summarizes these differences).

    Baselines and benchmarks: the controls in the experiments are a standard-trained model of the same architecture (λ=µ=0), L1/L2 weight decay regularization (Appendix D.3), and naive adversarial weight training (Appendix G); the benchmarks are MNIST and CIFAR-10.

    The authors position this paper as: under the different setting of worst-case weight perturbations, providing both a margin robustness bound and a generalization bound, and designing a training loss based on them.

  3. How does the paper address this problem?

    First derive the worst-case upper bound of the pairwise margin under each perturbation setting, then analyze the generalization gap of the robust surrogate loss using Rademacher complexity, and finally design a trinomial training loss based on this.

    Overall approach: transform the min-max robust training that is difficult to solve directly under weight perturbations into a computable upper bound on the worst-case error of the margin, then add the upper-bound term and a generalization regularization term to the training loss, yielding the theory-driven loss `∗ (Eq. (2)).

    Problem Setup and Notation

    • Model: L-layer feedforward network fW(x) = WL(...ρ(W1x)...), activation function ρ non-negative, monotone, 1-Lipschitz (including ReLU), K-class classification.
    • Perturbation model: each layer's weights have an independent budget εk within an element-wise l∞ ball, denoted IB∞W(ε); three settings: single-layer (N layers), all-layer (I=[L]), selected multiple layers (I⊆[L]).
    • Core quantity: pairwise margin fWij(x) = fWi(x) − fWj(x), i.e. the output score difference between two classes; taking i, j as the top-1 and second-highest classes can indicate robustness under perturbation.

    Worst-case Margin Bounds (Theorem 1–3)

    • Single-layer perturbation (Theorem 1, N≠L): the post-perturbation margin upper bound is the original margin plus an error term ∆(εN; zN−1; f), where the error grows with εN, the product of the (1,∞) norms of the subsequent layers' weights, and the l1 norm of the preceding layer's output; when N=L (Lemma 1) the upper bound is 2εL·‖zL−1‖1.
    • All-layer perturbation (Theorem 2): using the single-layer analysis as a building block, error is propagated inductively layer by layer; the upper bound is the sum of the input-layer error and intermediate-layer errors plus the final-layer error 2εL‖z*L−1‖1, where z* is the layer output after perturbing each layer's weights in the direction that maximizes the l1 norm of the output.
    • Selected multiple layers (Theorem 3): sum the errors of the layers in the index set I, with the final-layer error carrying the indicator function 1(L∈I); this expression unifies the single-layer and all-layer cases, and the error term is denoted ηWij(x|I). Appendix A.4 extends the results to convolutional networks using Toeplitz matrices (Theorem 5).

    Robust Surrogate Loss and Generalization Bound (Theorem 4)

    • Surrogate loss: the robust training objective is min maxŴ∈IB∞(ε) `(fŴ(x), y), but the inner maximization is non-concave and difficult to compute exactly; the authors use the margin bound to construct an upper-bound surrogate. Taking ramp loss as an example (Lemma 2), the surrogate loss is φγ(M(fW(x), y) − Ψ(fW(x))), where Ψ is the worst-case error term; the cross-entropy version is in Appendix B.2.
    • Generalization bound (Theorem 4): for a hypothesis class with bounded weight norms, the adversarial population risk R(f) ≤ adversarial empirical risk Rn(f) + (1/γ)·RS(MF) + RS(ΨF) + 3√(log(2/δ)/2n). The authors point out that if the product of the weight norms of each layer in RS(ΨF) is unconstrained, the generalization gap becomes larger, so a norm penalty should be added to all weight matrices.

    Theory-driven Loss Design (Eq. (2))

    • Three-term structure: ∗ = cls + λ·maxy′≠y{ηWy′y(x|I)} + µ·Σm(‖(Wm)T‖1,∞ + ‖Wm‖1,∞), which are respectively the standard classification loss, the robust term from Theorem 3, and the generalization regularization term from Theorem 4; the authors state that the standard L1 penalty also applies.
    • Evaluation attack (weight PGD): adapt the input PGD of Madry et al. [12]: starting from the trained W, perform iterative ascent along the sign gradient of the standard loss with respect to W, then clip element-wise by ε centered at W, with step size α; the paper uses two settings, 200 steps and 100 steps.
    • Implementation details: experiments use cross-entropy as `cls, the all-layer perturbation bound (I=[L]), a uniform ε for each layer, SGD with momentum, learning rate 0.01, batch size 32, 20 epochs.
  4. What experiments did the paper conduct?

    On the MNIST fully connected network and the CIFAR-10 convolutional network, verified with weight PGD attacks: increasing µ reduces the generalization gap, joint training improves robust accuracy, and is more robust to quantization.

    Experimental Setup

    • Models tested: 4-layer fully connected network (128-64-32-10, ReLU, no bias), MNIST; Appendix D.4 uses a network with 2 convolutional layers (32 and 64 5x5 filters) plus 3 fully connected layers (128, 64, 10), CIFAR-10.
    • Datasets: MNIST (10 classes of handwritten digits); the generalization experiments follow the setup of [29], training with 1000 samples; Appendix D.4 uses CIFAR-10.
    • Baselines: standard trained model (λ=µ=0); L1 and L2 weight decay regularization (Appendix D.3); naive adversarial weight training (Appendix G).
    • Metrics: test accuracy under weight PGD attack (robust accuracy), empirical generalization gap (training accuracy − test accuracy), AUC of the robust accuracy curve, training time per epoch.
    • Attack setup: weight PGD, 200 steps (100 steps in Appendix D.5), perturbation radius εtest; during training εtrain is 0.01 or 0.05, with the same budget for each layer.
    • Training setup: SGD with momentum, learning rate 0.01, batch size 32, 20 epochs; hardware is an Intel Xeon E5-2620v4 CPU and an NVIDIA TITAN Xp GPU. The paper does not report the number of random-seed repetitions or error bars (Checklist 3(c)).

    Main Results

    Main results are in Figure 1 (line plots, no numerical values in the converted text) and Table 6 (Appendix G, εtrain=0.01, weight PGD 200 steps, MNIST):

    Swipe horizontally to read the table

    Methodεtest=0.001εtest=0.005εtest=0.008εtest=0.01εtest=0.02
    Weight AT10%12%14%10%12%
    Ours80.3%50.2%39.87%39.83%39.57%
    Standard70.32%19.01%9.74%9.74%8.92%

    (According to Table 6; the εtest columns in the table also include 0.15, with the three methods at 14%, 39.8% and 8.92% respectively; the authors do not explain this column)

    • The authors state that the standard model is vulnerable to weight PGD attacks; using only the robust term (λ>0, µ=0) or only the regularization term (λ=0, µ>0) both improve robust accuracy.
    • The authors state that joint training with suitable coefficients (e.g. λ=0.0125, µ=0.045) further improves it, and the best model's robust accuracy AUC is about 2 times that of the standard model (Figure 1(b); the original text says the AUC improvement is significant, and the paper does not report a statistical test).
    • Figure 1(a) shows that for each εtrain, the generalization gap decreases as µ increases; the authors state this is consistent with Theorem 4.

    Regularization Term Comparison (Appendix D.3)

    • What was tested: replacing the regularization term in Eq. (2) with L1 or L2 weight decay, repeating the experiments of Figure 1(a).
    • Results: with L1 at εtrain=0.01, µ>0.002 already makes training accuracy below 10% (marked Failed to Converge in Table 2), and at εtrain=0.05 this happens for any µ>0; L2 cannot reduce the generalization gap as µ increases (Table 3, e.g. at εtrain=0.01 and εtest=0.001 the gap fluctuates between 0.85% and 5.87%).
    • Authors' interpretation: the authors state that only the loss in this paper can simultaneously reduce the generalization gap and improve robustness to weight PGD.

    Convolutional Network and CIFAR-10 (Appendix D.4)

    • What was tested: 2 convolutional layers + 3 fully connected layers network, εtrain=0.01, weight PGD 200 steps.
    • Results (Table 4): the standard model (λ=µ=0) is 58.73% at εtest=0, drops to 13.08% at εtest=0.001, and is 10% at εtest≥0.0019; among robust models, λ=4.5×10−4, µ=10−4 gives 36.82% at εtest=0.001 and 16.53% at εtest=0.0025.
    • Authors' interpretation: the authors state that the standard model's performance drops by about 5 times at εtest=0.001, while the robust model still retains about half its accuracy, consistent with the MNIST conclusion.

    Quantization, Runtime and Non-vacuous Bounds

    • Weight quantization (Appendix D.9, Figure 6): under 2-bit quantization the standard model's accuracy drops by 85.14% and the robust model's by 28.71%; the authors state the latter is about 1/3 of the former.
    • Runtime (Appendix D.8, Table 5): the standard model takes 5.125 seconds per epoch and the robust model (λ=0.01, µ=0.01; the table caption and the main text differ in how µ is written) 6.69 seconds; the authors state the two are comparable.
    • Non-vacuous generalization bounds (Appendix E, Figure 7): the authors state that on the standard model the bounds of [4] and [3] increase as the training set grows (consistent with [14]), whereas on the robust model both decrease as the training set grows, so under this paper's setting the corresponding bounds are non-vacuous; Figure 8 shows that the bounds still decrease when the regularization term is removed (λ=0.01, µ=0).

    Other Ablations and Analyses

    • Generalization gap at εtest=0 (Appendix D.1, Figure 2): the gap at εtrain=0 is lower than at other εtrain, with a similar trend as µ varies.
    • Test accuracy vs. εtrain and µ (Appendix D.2, Table 1): at εtrain=0.01 and εtest=0.001, accuracy rises from 67.93% to 75.10% as µ goes from 0 to 0.004.
    • 100-step attack (Appendix D.5, Figure 3): the authors state the conclusions are similar to 200 steps.
    • λ–µ grid (Appendix D.6, Figure 4): λ∈[0.01, 0.015], µ∈[0, 0.05]; the authors state there is a combination that gives the best robust accuracy, and that either being too large or too small reduces robustness.
    • Alternative regularization term (Appendix D.7, Figure 5): using Σm(log‖(Wm)T‖1,∞ + log‖Wm‖1,∞) as the regularizer, the authors state the effect is comparable and sometimes slightly better.
    • Weight distribution (Appendix F, Figure 9): the authors state that the weight distribution in each layer of the robust model is more concentrated than in the standard model.
  5. What are some points that can be further explored?

    The paper does not specifically discuss limitations; the experiments are limited to a fully connected network on MNIST and a small convolutional network on CIFAR-10, and no repeated experiments or error bars are reported.

    Limitations and future directions noted by the authors

    • The paper does not specifically discuss limitations. In the NeurIPS Checklist, the authors answered "No" to the item "Did you describe the limitations of your work?", and stated that the designed theory-driven loss can in theory be used for more applications without limitation (Checklist 1(b)).
    • Code and reproducibility: in Checklist 3(a), the authors state that code will be made available upon request (the main text states that code is in the supplementary material).

    Scope of experimental coverage

    • The models tested are a 4-layer fully connected network on MNIST (128-64-32-10) and a network with 2 convolutional layers + 3 fully connected layers on CIFAR-10, 2 in total (Section 4, Appendix D.4).
    • The datasets are MNIST and CIFAR-10; the generalization experiments use 1000 training samples (following the setting of [29]).
    • Attack evaluation is weight PGD (200 steps and 100 steps), with εtrain set to 0.01 or 0.05, and the same perturbation budget for each layer (Section 4, Appendix D.5).
    • Comparison methods include standard training, L1/L2 weight decay, and naive adversarial weight training (Appendix D.3, G).
    • The paper does not report repeated experiments with random seeds or error bars (Checklist 3(c)), and does not report the value of the weight PGD step size α.
  6. Summarize the main content of the paper

    The authors provide a theoretical characterization of margin robustness and the generalization gap under weight perturbations, propose a trinomial theory-driven loss, and validate it on MNIST/CIFAR-10 with weight PGD.

    This is a training-method paper with theory plus experimental validation, studying the robustness and generalization of neural networks under worst-case weight perturbations (such as fault injection, quantization).

    • Problem: the authors state that previous weight-perturbation research mostly evaluated generalization under the standard setting of random perturbations, lacking a theoretical characterization of the generalization gap and inter-class margin robustness under adversarial weight perturbations, and that min-max training for weight perturbations is not directly feasible because both optimization steps act on the parameters.
    • Method: derive worst-case upper bounds on the pairwise class margin for single-layer, all-layer and selected-layer perturbations respectively (Theorem 1–3, with the convolutional extension in Theorem 5); use Rademacher complexity to give a generalization bound for the robust surrogate loss (Theorem 4), pointing out that the product of the weight norms of each layer must be constrained; on this basis propose the loss `∗ = classification loss + λ·robust term + µ·weight (1,∞) norm regularization term (Eq. (2)).
    • Results: on MNIST with a 4-layer fully connected network, under weight PGD (200 steps), the model trained with this paper's loss reaches 80.3% accuracy at εtest=0.001, the standard model 70.32%, and naive weight AT 10% (Table 6); the authors state that the best model (λ=0.0125, µ=0.045) has a robust accuracy AUC about 2 times that of the standard model.
    • Results (continued): the generalization gap decreases as µ increases (Figure 1(a)); L1/L2 weight decay cannot reproduce this effect (Tables 2, 3); on the CIFAR-10 convolutional network the standard model drops to 13.08% at εtest=0.001, while the robust model reaches at most 36.82% (Table 4).
    • Results (continued): under 2-bit weight quantization the robust model's accuracy drops by 28.71% and the standard model's by 85.14% (Figure 6); the authors state that under this paper's setting the generalization bounds of [4] and [3] decrease as the training set grows, i.e. they are non-vacuous (Figure 7).
    • Authors' conclusion: the authors state that this analysis provides a theoretical basis for characterizing generalization and robustness under weight perturbations, and that the proposed loss can train networks that both generalize well and are robust to weight perturbations; the paper does not specifically discuss limitations, the experiments are limited to two small networks and MNIST/CIFAR-10, and repeated experiments and error bars are not reported.

Related papers

Show 2 more papers
Read originalarxiv.org