Formulating Robustness Against Unforeseen Attacks
Abstract
Existing defenses against adversarial examples such as adversarial training typically assume that the adversary will conform to a specific or known threat model, such as ℓ p perturbations within a fixed budget.
In this paper, we focus on the scenario where there is a mismatch in the threat model assumed by the defense during training, and the actual capabilities of the adversary at test time.
We ask the question: if the learner trains against a specific “source" threat model, when can we expect robustness to generalize to a stronger unknown “target" threat model during test-time?
Our key contribution is to formally define the problem of learning and generalization with an unforeseen adversary, which helps us reason about the increase in adversarial risk from the conventional perspective of a known adversary.
Applying our framework, we derive a generalization bound which relates the generalization gap between source and target threat models to variation of the feature extractor, which measures the expected maximum difference between extracted features across a given threat model.
Based on our generalization bound, we propose adversarial training with variation regularization (AT-VR) which reduces variation of the feature extractor across the source threat model during training.
We empirically demonstrate that AT-VR can lead to improved generalization to unforeseen attacks during test-time compared to standard adversarial training.
Our code is publicly available at https://github.com/inspire-group/variation-regularization .
Introduction
Neural networks have impressive performance on a variety of datasets (LeCun et al., 1998;
He et al., 2015; Krizhevsky et al., 2017; Everingham et al., 2010) but can be fooled by imperceptible perturbations known as adversarial examples (Szegedy et al., 2014).
The conventional paradigm to mitigate this threat often assumes that the adversary generates these examples using some known threat model, primarily ℓ p balls of specific radius (Cohen et al., 2019;
Zhang et al., 2020b; Madry et al., 2018), and evaluates the performance of defenses based on this assumption.
This assumption, however, is unrealistic in practice.
In general, the learner does not know exactly what perturbations the adversary will apply during test-time.
To bridge the gap between the setting of robustness studied in current adversarial ML research and robustness in practice, we study the problem of learning with an unforeseen adversary .
In this problem, the learner has access to adversarial examples from a proxy “source" threat model but wants to be robust against a more difficult “target" threat model used by the adversary during test-time.
We ask the following questions:
When can we expect robustness on the source threat model to generalize to the true unknown target threat model used by the adversary?
How can we design a learning algorithm that reduces the drop in robustness from source threat model to target threat model?
To address the first question, we introduce unforeseen adversarial generalizability which provides a framework for reasoning about what types of learning algorithms produce models that generalize well to unforeseen attacks.
Based on this framework, we derive a generalization bound which relates the difference in adversarial risk across source and target threat models to a quantity we call variation: the expected maximum difference between extracted features across a given threat model.
Our bound addresses the second question; it suggests that learning algorithms that bias towards models with small variation across the source threat model exhibit smaller drop in robustness to particular unforeseen attacks.
Thus, we propose adversarial training with variation regularization (AT-VR) to improve robustness to unforeseen attacks.
We then empirically demonstrate that AT-VR improves generalization to unforeseen attacks during test-time compared to standard adversarial training across multiple datasets and architectures.
Our contributions are as follows:
We formally define the problem of learning with an unforeseen adversary with respect to adversarial risk.
We make the case that one way of learning with an unforeseen adversary is to ensure that the gap between the empirical adversarial risk measured on the source adversary and the expected adversarial risk on the target adversary remains small.
To this end, we define unforeseen adversarial generalizability which provides a framework for understanding under what conditions we would expect small generalization gap.
Under our framework for generalizability, we derive a generalization bound for generalization across threat models.
Our bound relates the generalization gap to a quantity we define as variation, the expected maximum difference between extracted features across a given threat model.
We demonstrate that under certain conditions, we can decrease this upper bound while only using information about the source threat model .
Using our bound, we propose a regularization term which we call variation regularization.
We incorporate this regularization term into adversarial training, leading to a learning algorithm that we call AT-VR.
AT-VR incorporates the variation across the source threat model into the training objective in order to improve robust generalization to unforeseen attacks.
We find that this technique can lead to improved robustness on unforeseen attacks across datasets such as CIFAR-10, CIFAR-100, and ImageNette over standard adversarial training.
We achieve state-of-the-art accuracy on unforeseen threat models when combining variation regularization with perceptual adversarial training (PAT).
We incorporate variation regularization into PAT (Laidlaw et al., 2021) which uses an LPIPS-based source threat model.
We find that PAT-VR achieves SOTA robust accuracy on LPIPS-based attacks, improving over PAT by 21%.
Additionally,
PAT-VR achieves SOTA robust accuracy on a union of ℓ ∞ , ℓ 2 , spatially transformed (Xiao et al., 2018), and recolor attacks (Laidlaw & Feizi, 2019).
Related Works
Adversarial examples and defenses Previous studies have shown that neural networks can be fooled by perturbations known as adversarial examples, which are imperceptible to humans but cause NNs to predict incorrectly with high confidence (Szegedy et al., 2014).
These adversarial examples can be generated by various threat models including ℓ p perturbations, spatial transformations (Xiao et al., 2018), recoloring (Laidlaw & Feizi, 2019), and broader threat models such as fog and snow distortions (Kang et al., 2019).
While many defenses have been proposed, most defenses provide guarantees for specific threat models (Cohen et al., 2019;
Zhang et al., 2020b; Croce & Hein, 2020a;
Yang et al., 2020; Zhang et al., 2020a)
or use knowledge of the threat model during training (Madry et al., 2018;
Zhang et al., 2019; Wu et al., 2020a; Tramèr & Boneh, 2019; Maini et al., 2020).
Adversarial training is a popular defense framework in which a model is trained using adversarial examples generated by a particular threat model, such as ℓ 2 or ℓ ∞ attacks (Madry et al., 2018;
Zhang et al., 2019; Wu et al., 2020a).
Prior works have also extended adversarial training to defend against unions of attack types such as unions of ℓ p -balls (Maini et al., 2020; Tramèr & Boneh, 2019) and against stronger adversaries more aligned to human perception (Laidlaw et al., 2021).
Bounds for Learning with Adversarial Examples
An interesting body of work studies generalization bounds for specific attacks Cullina et al.
; Attias et al.
; Montasser et al.
Raghunathan et al.
; Chen et al.
; Diakonikolas et al.
Yu et al.
; Diochnos et al.
In particular, they study generalization in the setting where the learning algorithm minimizes the adversarial risk on the training set and hopes to generalize to same adversary during test-time.
Montasser et al.
(2021) provide bounds for the problem of generalizing to an unknown adversary with oracle access to that adversary during training.
Our work differs since we study generalization and provide bounds under the setting in the learner only has access to samples from a weaker adversary than present at test-time.
“Unforeseen" attacks and defenses While several prior works have studied “unforeseen" attacks (Kang et al., 2019; Stutz et al., 2020; Laidlaw et al., 2021; Jin & Rinard, 2020)
, these works are empirical works, and the term “unforeseen attack" has not been formally defined.
Kang et al.
(2019) first used the term “unforeseen attack" when proposing a set of adversarial threat models including
Snow, Fog, Gabor, and JPEG to evaluate how well defenses can generalize from ℓ ∞ and ℓ 2 to broader threat models.
Stutz et al.
and
Chen et al.
(2022) propose adversarial training based techniques with a mechanism for abstaining on certain inputs to improve generalization from training on ℓ ∞ to stronger attacks including ℓ p attacks of larger norm.
Other defenses against “unforeseen attacks" consider them to be attacks that are not used during training, but not necessarily stronger than those used in training.
For instance, Laidlaw et al.
propose using LPIPS (Zhang et al., 2018), a perceptually aligned image distance metric, to generate adversarial examples during training.
They demonstrate that by training using adversarial examples using this distance metric, they can achieve robustness against a variety of adversarial threat models including ℓ ∞ , ℓ 2 , recoloring, and spatial transformation.
However, the LPIPS attack is the strongest out of all threat models tested and contains a large portion of those threat models.
To resolve these differences in interpretation of “unforeseen attack", we provide a formal definition of learning with an unforeseen adversary.
Domain Generalization A problem related to generalizing to unforeseen attacks is the problem of domain generalization under covariate shift.
In the domain generalization problem, the learner has access to multiple training distributions and has the goal of generalizing to an unknown test distribution.
(Albuquerque et al., 2019) demonstrate that when the test distribution lies within a convex hull of the training distributions, learning is feasible.
(Ye et al., 2021) propose a theoretical framework for domain generalization in which they derive a generalization bound in terms of the variation of features across training distributions.
We focus on the problem of generalizing to unforeseen adversaries and demonstrate that a generalization bound in terms of variation of features across the training threat model exists.
Adversarial Learning with an Unforeseen Adversary
Notations We use D =
( X , Y ) to denote the data distribution and D m to denote a dataset formed by m iid samples from D .
We use X to denote the support of X .
To match learning theory literature, we will refer to the defense as a learning algorithm A , which takes the adversarial threat model and training data as inputs and outputs the learned classifier ( ˆ f
= A ( S, D m ) where S is the threat model).
We use F to denote the function class that A is applied over and A ( S, D m ) ∈ F .
F = G ◦H denotes a function class where
[Equation]
In this section, we will define what constitutes an unforeseen attack and the learner’s goal in the presence of unforeseen attacks.
We then introduce unforeseen adversarial generalizability which provides a framework for reasoning about what types of learning algorithms give models that generalize well to unforeseen adversaries.
3.1 Formulating Learning with an Unforeseen Adversary
To formulate adversarial learning with an unforeseen adversary, we begin by defining threat model and adversarial risk.
We will then use these definitions to explain the goal of the learner in the presence of an unforeseen adversary.
Definition 3.1 (Threat Model) .
The threat model is defined by a neighborhood function N ( · ) :
X → { 0 , 1 } X .
For any input x ∈ X , N ( x ) contains x .
Definition 3.2 (Expected and Empirical Adversarial Risk) .
We define expected adversarial risk for a model f with respect to a threat model N as L N ( f ) =
E ( x,y )
∼D max x ′ ∈ N ( x ) ℓ ( f ( x ′ ) , y ) where ℓ is a loss function.
In practice, we generally do not have access to the true data distribution D , but have m iid samples { ( x i , y i ) } mi =1 .
We can approximate L N ( f ) with the empirical adversarial risk defined as ˆ L N ( f )
= 1 m (cid:80) mi =1 max x ′ i ∈ N ( x i ) ℓ ( f ( x ′ i ) , y i )
In adversarial learning, the learner’s goal is to find a function f ∈ F that minimizes L T where T threat model used by the adversary.
We call T the target threat model .
We call the threat model that the learner has access to during training the source threat model .
We divide the adversarial learning problem into 2 cases, learning with a foreseen adversary and learning with an unforeseen adversary.
To distinguish between these 2 cases, we first define the subset operation for threat models.
Definition 3.3 (Threat Model Subset and Superset) .
We call a threat model S a subset of another threat model T (and T a superset of S )
if S ( x ) ⊆ T ( x ) almost everywhere in X .
We denote this as
S ⊆ T (or T ⊇ S ).
If S ( x ) ⊂ T ( x ) almost everywhere in X , then we call S a strict subset of T (and
T a strict superset of S ) and denote this as S ⊂ T (or T ⊃ S ) .
Learning with a Foreseen Adversary In learning with a foreseen adversary, the target threat model
T is a subset of the source threat model S ( T ⊆ S ).
The learner has access to S and a dataset D m of m iid samples from the data distribution D .
The learner would like to use a learning algorithm A for which f
= A ( S, D m ) achieves L T ( f ) <
ϵ for some small ϵ > 0 .
The learner cannot compute L T ( f ) , but can compute ˆ L S ( f ) ≥ ˆ L T ( f ) .
This setting of learning with a foreseen adversary represents when the adversary is weaker than assumed by the learner and since L S ( f ) ≥ L T ( f ) , which means that as long as the learner can achieve L S ( f ) <
ϵ , then they are guaranteed that L T ( f ) <
ϵ .
Learning with an Unforeseen Adversary In learning with an unforeseen adversary, the target threat model T is a strict superset of the source threat model S ( T ⊃ S ).
In this setting, we call T an unforeseen adversary.
The learner has access to S and a dataset D m of m iid samples from the data distribution D .
The learner would like to use a learning algorithm A for which f
= A ( S, D m ) achieves L
T ( f ) < ϵ for some small ϵ > 0 .
This setting of learning with an unforeseen adversary represents when the adversary is strictly stronger than assumed by the learner.
Compared to learning with a foreseen adversary, this problem is more difficult since L S ( f ) may not be reflective of L T ( f ) .
By construction L T ( f ) ≥ L S ( f ) , but it is unclear how much larger L T ( f ) is.
When can we guarantee that L T ( f ) is close to L S ( f ) ?
We will address this question in the Section 3.2 when we define threat model generalizability and Section 4 when we provide a bound for L T ( f ) − L S ( f ) .
3.2 Formulating Generalizability with an Unforeseen Adversary
How should we define A that performs well against an unforeseen adversary?
One way is to have f
=
A ( S, D m ) achieves small ˆ L S ( f ) (which can be measured by A ) while ensuring that ˆ L S ( f ) is close to L T ( f ) .
This leads us to the following definition for generalization gap.
Definition 3.4 (Generalization Gap) .
For threat models S and T , the generalization gap is defined as
L T ( f ) − ˆ L S ( f ) .
We observe that
[Equation]
We note that in the special case of learning with a foreseen adversary, L T ( f ) − L S ( f ) ≤ 0 , so
L T ( f ) − ˆ L S ( f ) ≤ L S ( f ) − ˆ L S ( f ) and bounding the generalization gap be achieved by bounding the sample generalization gap, which has been studied by prior works (Attias et al., 2019; Raghunathan et al., 2019; Chen et al., 2020; Yu et al., 2021).
We would like to ensure that the generalization gap is small with high probability.
We can achieve this by ensuring that both the sample generalization gap and threat model generalization gap are small.
This leads us to define robust sample generalizability and threat model generalizability which describe conditions necessary for us to expect the respective generalization gaps to be small.
We then combine these generalizability definitions and define unforeseen adversarial generalizability which describes the conditions necessary for a learning algorithm to be able to generalize to unforeseen attacks.
Definition 3.5 (Robust Sample Generalizability) .
A learning algorithm
A robustly ( ϵ ( · ) , δ ) -sample generalizes across function class F on threat model S
where ϵ : N → R + , if for any distribution D when running A on m iid samples D m from D , we have
[Equation]
Definition 3.5 implies that any learning algorithm that ( ϵ ( · ) , δ ) -robustly sample generalizes across our chosen hypothesis class F with ϵ ( m ) << 1 , δ << 1 , we can achieve small sample generalization gap with high probability.
We now define generalizability for the threat model generalization gap.
Definition 3.6 (Threat Model Generalizability) .
Let S be the source threat model used by the learner.
A learning algorithm A ( ϵ ( · , · ) , δ ) -robustly generalizes to target threat model T where ϵ : T × N → R + ∪ {∞} and δ ∈ [0 , 1] if for any data distribution D and any training dataset D m with m iid samples from
D , we have:
[Equation]
We note that the Definition 3.6 considers generalization to a given T , which does not fully account for the unknown nature of T , since from the learner’s perspective, the learner does not know which threat model it wants L T to be small for.
We address this in the following definition where we combine
Definitions 3.5 and 3.6 and define generalizability to unforeseen adversarial attacks.
Definition 3.7 (Unforeseen Adversarial Generalizability) .
A learning algorithm A on function class F with source adversary S , ( ϵ ( · , · ) , δ ) -robustly generalizes to unforeseen threat models where ϵ : N × N → R + ∪{∞} if there exists ϵ 1 , ϵ 2 with ϵ 1 ( m )+ ϵ 2 ( T, m ) ≤ ϵ ( T, m ) such that A robustly ( ϵ 1 , δ ) -sample generalizes and ( ϵ 2 , δ ) -robustly generalizes to any threat model T .
We remark that in Definition 3.7, ϵ is a function of T , which accounts for differences in difficulty of possible target threat models.
Ideally, we would like ϵ ( T, m ) at sufficiently large m to be small across a set of reasonable threat models T (ie.
imperceptible perturbations) and expect it to be large (and possibly infinite) for difficult or unreasonable threat models (ie. unbounded perturbations).
A Generalization Bound for Unforeseen Attacks
While prior works have proposed bounds on sample generalization gap (Attias et al., 2019; Raghunathan et al., 2019; Chen et al., 2020; Yu et al., 2021), to the best of our knowledge, prior works have not provided bounds on threat model generalization gap.
In this section, we demonstrate that we can bound the threat model generalization gap in terms of a quantity we define as variation, the expected maximum difference across features learned by the model across the target threat model.
We then show that with the existence of an expansion function, which relates source variation to target variation, any learning algorithm which with high probability outputs a model with small source variation can achieve small threat model generalization gap.
4.1 Relating generalization gap to variation
We now consider function classes of the form F = G ◦ H where ∀ g ∈ G , g : R d → R K is a top level classifier into K classes and ∀ h ∈ H , h : X → R d is a d -dimensional feature extractor.
Since the top classifier g is fixed for a function f , if h (ˆ x ) i , i ∈ [1 ...d ] fluctuates a lot across the threat model ˆ x ∈ T ( x ) , then the adversary can manipulate this feature to cause misclassification.
The relation between features and robustness has been analyzed by prior works such as (Ilyas et al., 2019; Tsipras et al., 2019; Tramèr & Boneh, 2019).
We now demonstrate that we can bound the threat model generalization gap in terms of a measure of the fluctuation of h across T , which we call variation .
Definition 4.1 (Variation) .
The variation of a feature vector h ( · ) : X → R d across a threat model N is given by
[Equation]
Theorem 4.2 (Variation-Based Threat Model Generalization Bound) .
Let S denote the source threat model and D denote the data distribution.
Let F = G ◦ H where G is a class of Lipschitz classifiers with Lipschitz constant upper bounded by σ G .
Let the loss function be ρ -Lipschitz.
Consider a learning algorithm
A over F and denote f =
A ( S, D m ) =
g ◦ h .
If with probability 1 − δ over the randomness of D m , V ( h, T ) ≤ ϵ ( T, m ) where
ϵ : T × N → R + ∪ {∞} , then A ( ρσ G ϵ ( T, m ) , δ ) - robustly generalizes from S to T .
Theorem 4.2 shows we can bound the threat model generalization gap between any source S and unforeseen adversary T in terms of variation across T .
With regards to Definition 3.6, Theorem 4.2 suggests that any learning algorithm over F that with high probability outputs models with low variation on the target threat model can generalize well to that target.
4.2 Relating source and target variation
Since the learning algorithm
A cannot use information from T , it is unclear how to define such A that achieves small V ( h, T ) .
We address this problem by introducing the notion of an expansion function, which relates the source variation (which can be computed by the learner) to target variation.
Definition 4.3 (Expansion Function for Variation (Ye et al., 2021)) .
A function s : R + ∪ { 0 } → R + ∪ { 0 , + ∞} is an expansion function relating variation across source threat model S to target threat model T if the following properties hold:
s ( · ) is monotonically increasing and s ( x ) ≥ x, ∀ x ≥2.
lim x → 0 + s ( x ) =
s (0) =3.
For all h that can be modeled by function class F , s ( V ( h, S ))
≥ V ( h, T )
When an expansion function for variation from S to T exists, then we can bound the threat model generalization gap in terms of variation on S .
This follows from Theorem 4.2 and Definition 4.3.
Corollary 4.4 (Source Variation-Based Threat Model Generalization Bound) .
Let S denote the source threat model and D denote the data distribution.
Let F = G ◦ H where G is a class of Lipschitz classifiers with Lipschitz constant upper bounded by σ G .
Let the loss function be ρ -Lipschitz.
Let T be any unforeseen threat model for which an expansion function s from S to T exists.
Consider a learning algorithm
A over F and denote f =
A ( S, D m ) =
g ◦ h .
If with probability 1 − δ over the randomness of D m , s ( V ( h, S ))
≤ ϵ ( T, m ) where
ϵ : T × N → R + ∪ {∞} , then A ( ρσ
G ϵ ( T, m ) , δ ) -robustly generalizes from S to T .
Corollary 4.4 allows us to relate generalization across threat models of a model f = g ◦ h to s ( V ( h, S )) instead of V ( h, T ) .
While this expression is still dependent on the target threat model T (since s is dependent on T ), we can reduce s ( V ( h, S )) without knowledge of T due to the monotonicity of the expansion function.
Thus, provided that an expansion function exists, we can use techniques such as regularization in order to ensure that our learning algorithm actively chooses models with low source variation.
This result leads to the question: when does the expansion function exist?
4.3 When does the expansion function exist?
We now demonstrate a few cases in which the expansion function exists or does not exist.
We begin by providing basic examples of source threat models S and target threat models T without constraints on function class.
Proposition 4.5.
When S = T , an expansion function s exists and is given by s ( x ) = x .
Proposition 4.6.
Let S = { x } , and T be a threat model such that S ⊂ T .
Then, for all feature extractors h , we have that V ( h, S )
= 0 while V ( h, T ) can be greater than 0.
In this case, no expansion function exists such that s ( V ( h, S )) ≥ V ( h, T ) .
While we did not consider a constrained function class in the previous two settings, the choice of function class can also impact the existence of an expansion function.
For instance, in the setting of Proposition 4.6, if we constrain F to only use feature extractors with a constant output, then the expansion function s ( x ) = x is valid.
We now consider the case where our function class F uses linear feature extractors and derive expansion functions for ℓ p adversaries.
Theorem 4.7 (Linear feature extractors with ℓ p threat model ( p ∈ N ∪ + ∞ )) .
Let inputs x ∈ R n and corresponding label y ∈
[1 ...K ] .
Consider S ( x ) =
{ ˆ x | ||
ˆ x − x || p ≤ ϵ 1 } and U ( x ) =
{ ˆ x | ||
ˆ x − x || q ≤ ϵ 2 } with p, q ∈ N + , p, q > 0 .
Define target threat model T ( x ) =
S ( x ) ∪ U ( x ) .
Consider a linear feature extractor with bounded condition number: h ∈ { Wx + b | W ∈ R d × n , b ∈ R d , σ max ( W )
[Equation]
min
[Equation]
W ) ≤
B < ∞} .
Then, an expansion function exists and is linear.
Theorem 4.7 demonstrates that in the case of a linear feature extractor a linear expansion function exists for any data distribution from a source ℓ p adversary to a union of ℓ p adversaries.
This result suggests that with a function class using linear feature extractors, we can improve generalization to ℓ p balls with larger radii by using a learning algorithm that biases towards models with small V ( h, S ) .
We demonstrate this in Appendix D where we experiment with linear models on Gaussian data.
We also provide visualizations of expansion function for a nonlinear model (ResNet-18) on CIFAR-10 in
Section 5.6.
Adversarial Training with Variation Regularization
Our generalization bound from Corollary 4.4 suggests that learning algorithms that bias towards small source variation can improve generalization to other threat models when an expansion function exists.
In this section, we propose adversarial training with variation regularization (AT-VR) to improve generalization to unforeseen adversaries and evaluate the performance of AT-VR on multiple datasets and model architectures.
5.1 Adversarial training with variation regularization
To integrate variation into AT, we consider the following training objective:
[Equation]
where λ ≥ 0 is the regularization strength.
For the majority of our experiments in the main text, we use the objective of PGD-AT (Madry et al., 2018) as the approximate empirical adversarial risk.
We note that this can be replaced with other forms of AT such as TRADES (Zhang et al., 2019).
We can approximate empirical variation by using gradient-based methods.
For example, when N ( x ) is a ℓ p ball around x , we compute the variation term by using PGD to simultaneously optimize over x 1 and x 2 .
We discuss methods for computing variation for other source threat models in Appendix E.10.
5.2 Experimental Setup
We investigate the performance of training neural networks with AT-VR on image data for a variety of datasets, architectures, source threat models, and target threat models.
We also combine VR with perceptual adversarial training (PAT) (Laidlaw et al., 2021), the current state-of-the-art for unforeseen robustness, which uses a source threat model based on LPIPS (Zhang et al., 2018) metric.
Datasets We train models on CIFAR-10, CIFAR-100, (Krizhevsky et al., 2009) and ImageNette (Howard).
ImageNette is a 10-class subset of ImageNet (Deng et al., 2009).
Model architecture On CIFAR-10, we train ResNet-18 (He et al., 2016), WideResNet(WRN)-2810 (Zagoruyko & Komodakis, 2016), and VGG-16 (Simonyan & Zisserman, 2015) architectures.
On ImageNette, we train ResNet-18 (He et al., 2016).
For PAT-VR, we use ResNet-50.
For all architectures, we consider the feature extractor h to consist of all layers of the NN and the top level classifier g to be the identity function.
We include experiments for when we consider h to be composed of all layers before the fully connected layers in Appendix F.
Source threat models Across experiments with AT-VR, we consider 2 different source threat models: ℓ ∞ perturbations with radius 8255 and ℓ 2 perturbations with radius 0.5.
For PAT-VR, we use LPIPS computed from an AlexNet model (Krizhevsky et al., 2017) trained on CIFAR-10.
We provide additional details about training procedure in Appendix C. We also provide results for additional source threat models such as StAdv and Recolor in Appendix E.10.
Target threat models We evaluate AT-VR on a variety of target threat models including, ℓ p adversaries ( ℓ ∞ , ℓ 2 , and ℓ 1 adversaries), spatially transformed adversary (StAdv) (Xiao et al., 2018), and Recolor adversary (Laidlaw & Feizi, 2019).
For StAdv and Recolor threat models, we use the original bounds from (Xiao et al., 2018) and (Laidlaw & Feizi, 2019) respectively.
For all other threat models, we specify the bound ( ϵ ) within the figures in this section.
We also provide evaluations on additional adversaries including Wasserstein, JPEG, elastic, and LPIPS-based attacks in Appendix
E.7 for CIFAR-10 ResNet-18 models.
Baselines We remark that we are studying the setting where the learner has already chosen a source threat model and during testing the model is evaluated on a strictly larger unknown target.
Because of this, for AT-VR experiments, we use standard PGD-AT (Madry et al., 2018)
(AT-VR with λ = 0 ) as a baseline.
For PAT-VR experiments, we use PAT (PAT-VR with λ = 0 ) as a baseline.
We note that VR can be combined with other training techniques such as TRADES (Zhang et al., 2019) and provide results in Appendix E.9.
[Table]
5.3 Performance of AT-VR across different imperceptible target threat models
We first investigate the impact of AT-VR on robust accuracy across different target threat models that are strictly larger than the source threat model used for training.
To enforce this, we evaluate robust accuracy on a target threat model that is the union of the source with a different threat model.
For ℓ ∞ and ℓ 2 attacks, we measure accuracy using AutoAttack (Croce & Hein, 2020a)
[Table]
which reports the lowest robust accuracy out of 4 different attacks: APGD-CE, APGD-T,
FAB-T
[Table]
and Square.
For ℓ ∞ and ℓ 2 threat models, we use radius ϵ = 12255 and ϵ = 1 for evaluating unforeseen robustness.
We report clean accuracy, source accuracy (robust accuracy on the source threat model), and robust accuracy across various targets in Table 1.
We present results with additional strengths of VR in
Appendix E.5.
AT-VR improves robust accuracy on broader target threat models.
We find that overall across datasets, architecture, and source threat model, using AT-VR improves robust accuracy on unforeseen targets but trades off clean accuracy.
For instance, we find that on CIFAR-10, our ResNet-18 model using VR improves robustness on the union of all attacks from 2.48% to 12.59% for ℓ ∞ source and from 0.33% to 11.77% for ℓ 2 .
The largest improvement we observe is a 33.64% increase in robust accuracy for the ResNet-18 CIFAR-10 with ℓ 2 source model on the StAdv target.
AT-VR maintains accuracy on the source compared to standard AT, but trades off clean accuracy.
We find that AT-VR is able to maintain similar source accuracy in comparson to standard
PGD AT but consistently trades off clean accuracy.
For example, for WRN-28-10 on CIFAR-10, we find that source accuracy increases slightly with VR (from 49.86% to 49.94%), but clean accuracy drops from 85.93% to 72.73%.
In Appendix E.5, where we provide results on additional values of regularization strength ( λ ), we find that increasing λ generally trades off clean accuracy but improves union accuracy .
We hypothesize that this tradeoff occurs because VR enforces the decision boundary to be smooth, which may prevent the model from fitting certain inputs well.
5.4 State-of-the-art performance with PAT-VR
We now combine variation regularization with PAT.
We present results in Table 2.
PAT-VR achieves state-of-the-art robust accuracy on AlexNet-based LPIPS attacks (PPGD and LPA).
Laidlaw et al.
(2021) observed that LPA attacks are the strongest perceptual attacks, and that standard AlexNet-based PAT with source ϵ = 1 can only achieve 9.8% robust accuracy on LPA attacks with ϵ = 0 .
In comparison, we find that applying variation regularization can significantly
[Table]
improve over performance on LPIPS attacks.
In fact, using variation regularization strength λ = 0 .while training with ϵ = 0 .
5 can achieve 29.7% robust accuracy on LPA, while training with λ = 0 .and
ϵ = 1 improves LPA accuracy to 30.8%.
PAT-VR achieves state-of-the-art union accuracy across ℓ ∞ , ℓ 2 , StAdv, and Recolor attacks.
We observe that as regularization strength λ increases, union accuracy also increases.
For source ϵ = 0 .
5 , we find that union accuracy increases from 2.1% without variation regularization to 24.9% with variation regularization at λ = 0 .
For source ϵ = 1 , we observe a 1% increase in union accuracy from λ = 0 to λ = 0 .
However, this comes at a trade-off with accuracy on specific threat models.
For example, when training with ϵ = 0 . 5 , we find that variation regularization at λ = 0 .
1 trades off accuracy on ℓ ∞ and ℓ 2 sources (7.4% and 7.2% drop in robust accuracy respectively), but improves robust accuracy on StAdv attacks from 5.8% to 44.9%.
Meanwhile, for ϵ = 1 , we find that at λ = 0 . 1 , variation regularization trades off accuracy on StAdv to improve accuracy across ℓ ∞ , ℓ 2 , and Recolor threat models.
Unlike AT-VR, PAT-VR maintains clean accuracy in comparison to PAT.
We find that after adding variation regularization, PAT-VR generally does not trade off additional clean accuracy in comparison to PAT.
In some cases (at source ϵ = 1 ), increasing variation regularization strength can even improve clean accuracy.
5.5 Influence of AT-VR on threat model generalization gap across perturbation size
[Figure]
In Section 5.3, we observed that AT-VR improves robust accuracy on a variety of unforeseen target threat models at the cost of clean accuracy.
This suggests that AT-VR makes the change in adversarial loss on more difficult threat models increase more gradually.
In this section, we experimentally verify this by plotting the gap between source and target losses (measured via cross entropy) across different perturbation strengths ϵ for ℓ p threat models ( p ∈ {∞ , 2 , 1 } ) for ResNet-18 models trained on CIFAR-10.
We present results for models using AT-VR with ℓ ∞ source attacks in Figure 1.
For these experiments, we generate adversarial examples using APGD from AutoAttack (Croce & Hein, 2020b).
We also provide corresponding plots for ℓ 2 source attacks in Appendix E.4.
We find that AT-VR consistently reduces the gap between source and target losses on ℓ p attacks across different target perturbation strengths ϵ .
We observe that this gap decreases as regularization increases across target threat models .
This suggests that VR can reduce the generalization gap across threat models, making the loss measured on the source threat model better reflect the loss measured on the target threat model, which matches our results from Corollary 4.4.
5.6 Visualizing the expansion function
The effectiveness of AT-VR suggests that an expansion function exists between across the different imperceptible threat models tested.
In this section, we visualize the expansion function between ℓ ∞ and ℓ 2 source and target pairs for ResNet-18 models on CIFAR-10.
We train a total of 15 ResNetmodels using PGD-AT with and without VR on ℓ 2 and ℓ ∞ source threat models.
We evaluate variation on models saved every 10 epochs during training along with the model saved at epoch with best performance, leading to variation computation on a total of 315 models for each source threat model.
[Figure]
The two rows represent the target adversary ( ℓ ∞ and ℓ 2 respectively).
We consider 4 cases: (1) ℓ ∞ source with radius 8255 to ℓ ∞ target with radius 16255 , (2) ℓ ∞ source with radius 8255 to a target consisting of the union of the source with an ℓ 2 threat model with radius 0 .
5 , (3) ℓ 2 source with radius 0 .to
a target consisting of the union of the source with an ℓ ∞ threat model with radius 8255 , and (4) ℓ 2 source with radius 0 .
5 to ℓ 2 target with radius 1.
In cases (2) and (3), since the target is taken to be the union of ℓ p balls, we approximate the variation of the union by taking the maximum variation across both ℓ p balls.
We plot the measured source vs target variation along with the minimum linear expansion function s in Figure 2.
We find that in all cases the distribution of source vs target variation measured across ResNetmodels is sublinear, and we can upper bound this distribution with a linear expansion function with relatively small slope.
Recall our finding in
Theorem 4.7 that for linear models there exists a linear expansion function across ℓ p norms.
We hypothesize that this property also appears for ResNet-18 models because neural networks are piecewise linear.
Discussion, Limitations, and Conclusion
We highlight a limitation in adversarial ML research: the lack of understanding of how much robustness degrades when a mismatch in source and target threat models occurs.
Our work takes steps toward addressing this problem by formulating the problem of learning with an unforeseen adversary and providing a framework for reasoning about generalization under this setting.
With this framework, we derive a bound for threat model generalization gap in terms of variation and use this bound to design an algorithm, adversarial training with variation regularization (AT-VR).
We highlight several limitations of our theoretical results: (1) the bounds provided can be quite loose and may not be good predictors of unforeseen loss, (2) while we show that an expansion function between ℓ p balls exists for linear models, it is unclear if that is the case for neural networks.
Additionally, we highlight several limitations of AT-VR: (1) its success depends on the existence of an expansion function, (2) VR trades off additional clean accuracy and increases computational complexity of training.
Further research on improving source threat models and the accuracy and efficiency of adversarial training algorithms can improve the performance of AT-VR.
Finally, we note that in some applications, such as defending against website fingerprinting (Rahman et al., 2020) and bypassing facial recognition based surveillance (Shan et al., 2020), adversarial examples are used for good, so improving robustness against adversarial examples may consequently hurt these applications.
Acknowledgments and Disclosure of Funding
We would like to thank Tianle Cai, Peter Ramadge and Vincent Poor for their feedback on this work.
This work was supported in part by the National Science Foundation under grants CNS-1553437 and
CNS-1704105, the ARL’s Army Artificial Intelligence Innovation Institute (A2I2), the Office of Naval
Research Young Investigator Award, the Army Research Office Young Investigator Prize, Schmidt
DataX award and Princeton E-ffiliates Award.
This material is also based upon work supported by the National Science Foundation Graduate Research Fellowship under Grant No. DGE-
Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation
Table
of
Contents A Discussion
of Related
Works
B Proofs of Theorems and Analysis of Bounds
B.1 Proof of Theorem 4.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
B.2 Impact of choice of source and target . . . . . . . . . . . . . . . . . . . . . . .
B.3 Proof of Theorem 4.7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
B.4 How well can
[Table]
predict loss on the
[Table]
for neural networks? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
C Additional Experimental Setup Details
D Experiments for
linear models
on
Gaussian data
D.1 Experimental Setup . .
D.2 Visualizing the expansion function for Gaussian data . . . . . . . . . . . . . . .
D.3 Generalization curves . .
D.4 Accuracies over regularization strength . . . . . . . . . . . . . . . . . . . . . .
D.
Evaluations on a separate test set . . . . . . . . . . . . . . . . . . . . . . . . .
E Additional Results for Logit Level AT-VR
E.1 Results on Additional Seeds . . . . . . . . . . . . . . . . . . . . . . . . . . . .
E.2 Expansion function on random features . . .
E.3 Expansion function between ℓ p and StAdv threat model . .
[Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table]
A Discussion of Related Works
Comparison to Ye et al.
Ye et al.
(2021) derive a generalization bound for the domain generalization problem in terms of variation across features.
They define variation as
V ρ ( ϕ, D ) = max y ∈Y sup e,e ′ ∈D ρ
( P ( ϕ ( X e ) | y ) , P ( ϕ ( X e ′ ) | y )) where D is a set of training distri- butions, ϕ :
X → R is a function that maps the input to a 1-D feature, ρ is a symmetric distance metric for distributions, and X e denotes inputs from domain e .
In comparison, we address the problem of learning with an unforeseen adversary and define unforeseen adversarial generalizability.
Our generalization bound using variation is an instantiation of our generalizability framework.
Additionally, we define a different measure of variation for threat models
V ( h, N ) =
E ( x,y )
∼D max x 1 ,x 2 ∈ N ( x ) || h
( x 1 ) , − h ( x 2 ) || 2 , which allows us to use it as regularization during training.
Comparison to Laidlaw et al.
Laidlaw et al.
(2021) proposes training with perturbations of bounded LPIPS (Zhang et al., 2018) since LPIPS metric is a better approximation of human perceptual distance than ℓ p metrics.
In their proposed algorithm, perceptual adversarial training (PAT), they combine standard adversarial training with adversarial examples generated via their LPIPS bounded attack method.
In terms of terminology introduced in our paper, the Laidlaw et al.
(2021) improve the choice of source threat model while using an existing learning algorithm (adversarial training).
Meanwhile, our work takes the perspective of having a fixed source threat model and improving the learning algorithm.
This allows us to combine our approach with various source threat models including the attacks used by Laidlaw et al.
(2021) in PAT (see Appendix E.10).
Comparison to Stutz et al.
and
Chen et al.
Stutz et al.
and
Chen et al.
(2022) address the problem of unforeseen attacks by adding a reject option in order to reject adversarial examples generated with a larger perturbation than used during training.
These techniques introduce a modified adversarial training objective that maximizes accuracy on perturbations within the source threat model and maximize rejection rate of large perturbations.
In comparison, we look at the problem of improving robustness on larger threat models instead of rejecting adversarial examples from larger threat models.
Our algorithm AT-VR actively tries to find a robust model that minimizes our generalization bound without abstaining on any inputs.
Comparison to Croce & Hein (2020a)
Croce & Hein (2020a) prove that certified robustness against ℓ 1 and ℓ ∞ bounded perturbations implies certified robustness against attacks generated with any ℓ p ball.
The size of this ℓ p certified radius is the radius of the largest ℓ p ball that can be contained in the convex hull of the ℓ 1 and ℓ ∞ balls for which the model is certifiably robust.
In our work, we are primarily interested in empirical robustness on target threat models that are supersets of the source threat model used.
We demonstrate that by using variation regularization, we can improve robust performance on unforeseen threat models (including larger ℓ p perturbations, StAdv, and Recolor) even when our learning algorithm optimizes for robust models on a single ℓ p ball.
Comparison to other forms of regularization for adversarial robustness Prior works in adversarial training propose regularization techniques enforcing feature consistency to improve the performance of adversarial training.
For example, TRADES adversarial training(Zhang et al., 2019) uses a regularization term in the objective to reduce trade-off between clean accuracy and robust accuracy compared with PGD adversarial training.
This regularization term takes the form: λ max ˆ x ∈ S ( x ) ℓ ( f ( x ) f
(ˆ x )) .
Our variation regularization differs from TRADES since we regularize ℓ 2 distance between extracted features.
Another regularization is adversarial logit pairing (ALP) (Kannan et al., 2018).
This regularization is also ℓ 2 based; in ALP, an adversarial example is first generated via x ′ =
max ˆ x ∈ S ( x ) ℓ ( f (ˆ x ) , y ) and the ℓ 2 distance between the logits of this adversarial example and the original image λ
|| f ( x ′ )
− f ( x ) || 2 is added to the training objective.
ALP can be thought of as a technique to make the logits of adversarial examples close to the logits of clean images.
Variation regularization ( λ max x ′ ,x ′′ ∈ S ( x ) || f
( x ′ )
− f ( x ′′ ) || 2 ) differs from ALP since it encourages the logits of any pair of images (not only adversarial examples) that lie within the source threat model to have similar features and does not use information about the label of the image.
Jin & Rinard (2020) propose a regularization technique motivated by concepts from manifold regularization.
Their regularization is computed with randomly sampled maximal perturbations p ∈ {± ϵ } d and applied to standard training.
Their regularization includes 2 terms, one which regularizes the hamming distance between the ReLU masks of the network for x − p and x + p across inputs x , and the second which regularizes the squared ℓ 2 distance between the network output on x − p and x + p ( || f ( x + p ) − f ( x − p ) || 22 ).
They demonstrate that using both regularization terms with ϵ ∈ [2 , 8] leads to robustness on ℓ ∞ , ℓ 2 , and Wasserstein attacks.
In comparison, our variation regularization is motivated from the perspective of generalization across threat models.
We use use smaller values of ϵ in conjunction with adversarial training and regularize worst case ℓ 2 distance between logits of any pair of examples within the source threat model.
B Proofs of Theorems and Analysis of Bounds B.1 Proof of Theorem 4.
Proof.
By definition of expected adversarial risk, we have that for any f ∈ F
[Equation]
By ρ -Lipschitzness of ℓ
[Equation]
By σ G Lipschitzness:
[Equation]
Since S ⊆ T :
[Equation]
Note that our learning algorithm A over F outputs a classifier with V ( h, T ) ≤ ϵ ( T, m ) with probability− δ .
Combining this with the above bound gives:
[Equation]
B.2 Impact of choice of source and target
In Theorem 4.2, we demonstrated a bound on threat model generalization gap that does not depend on source threat model, so this bound does not allow us to understand what types of targets are easier to generalize given a source threat model.
In this section, we will introduce a tighter bound in terms of Hausdorff distance, which takes both source and target threat model into account.
Definition B.1 (Directed Hausdorff Distance) .
Let A, B ⊂ X and let d : X × X
→ R be a distance metric.
The Hausdorff distance from A to B based on d is given by
[Equation]
Intuitively what this measures is, if we were to take every point in A and project it to the nearest point in set B , what is the maximum distance projection?
We can then derive a generalization bound in terms of Hausdorff distance based on feature space distance.
Theorem B.2 (Threat Model Generalization Bound with Hausdorff Distance) .
Let S denote the source threat model and D denote the data distribution.
Let F = G ◦ H .
Let G be a class of Lipschitz classifiers, where the Lipschitz constant is upper bounded by σ G .
Let ℓ be a ρ -Lipschitz loss function with respect to the 2-norm.
Then, for any target threat model T with S ⊆ T .
Let
d h :=
|| h
( x 1 ) − h ( x 2 )
|| 2 be the distance between feature extracted by the model.
Then,
[Equation]
Proof.
By definition of expected adversarial risk,
[Equation]
Note that since we are subtracting the max across S ( x ) , this expression is upper bounded by any choice of ˆ x ∈ S ( x ) .
Thus, we can choose ˆ x so that ℓ ( f (ˆ x ) , y ) is close to max x 1 ∈ T ( x ) ℓ ( f ( x 1 ) , y .
This gives us:
[Equation]
− ℓ ( f (ˆ x ) , y ))
By ρ -Lipschitzness of ℓ
[Equation]
By σ G Lipschitzness:
[Equation]
Since S ⊆ T :
[Equation]
We note that this bound is tighter than the variation based bound and goes to 0 when S = T .
Since this bound also depends on both S and T , we can also see that the “difficulty" of a target T with respect to a chosen source threat model S can be measured through the directed Hausdorff distance from T ( x ) to S ( x ) .
B.3 Proof of Theorem 4.
Lemma B.3 (Variation Upper Bound for ℓ p threat model, p ∈ N ∪ + ∞ ) .
Let inputs x ∈ R n and corresponding label y ∈
[1 ...K ] .
Let the adversarial constraint be given by T ( x )
= { ˆ x
| || ˆ x − x || p ≤ ϵ max } Let h be a linear feature extractor:
h ∈ { Wx + b | W ∈ R d × n , b ∈ R d } .
Then, variation is upper bounded by
[Equation]
Proof.
[Equation]
Consider the case where p > 2 .
Then, by Hölder’s inequality:
[Equation]
When p = 1 or p = 2 , then from 1, we have:
[Equation]
Lemma B.4 (Variation lower bound for ℓ p threat model, p ∈ N ∪ + ∞ ) .
Let inputs x ∈ R n and corresponding label y ∈
[1 ...K ] .
Let the adversarial constraint be given by T ( x )
= { ˆ x
| || ˆ x − x || p ≤ ϵ max } .
Let h be a linear feature extractor: h ∈ { Wx + b | W ∈ R d × n , b ∈ R d } .
Then, variation is lower bounded by
[Equation]
where σ min ( W ) denotes the smallest singular value of W .
Proof.
[Equation]
Then, for p ≥ 2 :
[Equation]
For p = 1 from 2, we have:
[Equation]
Lemma B.5 ( ℓ p threat models with larger radius, p ∈ N ∪ + ∞ ) .
Let inputs x ∈ R n and corresponding label y ∈
[1 ...K ] .
Let S ( x ) =
{ ˆ x | ||
ˆ x − x || p ≤ ϵ 1 } and T ( x ) =
{ ˆ x | ||
ˆ x − x || p ≤ ϵ 2 } where ϵ 2 ≥
ϵ 1 .
Consider a linear feature extractor with bounded condition number: h
[Equation]
R d
[Equation]
max
[Equation]
min
[Equation]
W ) ≤ B < ∞} .
Then a valid expansion function is given by:
[Equation]
Proof.
By Lemma B.3 and Lemma B.4, V ( h, T ) ≤ s ( V ( h, S )) .
Additionally, it is clear that s p satisfies properties of expansion function.
Lemma B.6 (Variation upper bound for the union of ℓ p and ℓ q threat models ( p, q ∈ N ∪ + ∞ )) .
Let inputs x ∈ R n and corresponding label y ∈
[1 ...K ] .
Consider T 1 ( x ) =
{ ˆ x | ||
ˆ x − x || p ≤ ϵ 1 } and T 2 ( x ) =
{ ˆ x | ||
ˆ x − x || q ≤ ϵ 2 } .
Define adversarial constraint T =
T 1 ∪ T 2 .
Let h be a linear feature extractor: h ∈ { Wx + b | W ∈ R d × n , b ∈ R d } .
Let v ( p, h, T ) be defined as
[Equation]
where σ max ( W ) denotes the largest singular value of W .
Then variation is upper bounded by:
[Equation]
Proof.
[Equation]
Since T = T 1 ∪ T 2 , max x 1 ,x 2 ∈ T ( x ) || x 1 − x 2 || 2 can be upper bounded by the diameter of the hypersphere that contains both T 1 and T 2 .
We can compute this diameter by taking the max out of the diameter of the hypersphere containing T 1 and the diameter of the hypersphere containing T 2 .
This was computed in proof of Lemma B.3 to bound the case of a single ℓ p norm.
Thus,
[Equation]
where the expression for v follows from the result of Lemma B.3.
Lemma B.7 ( ℓ p to union of ℓ p and ℓ q threat model ( p, q ∈ N ∪ + ∞ ) ) .
Let inputs x ∈ R n and corresponding label y ∈
[1 ...K ] .
Consider S ( x ) =
{ ˆ x | ||
ˆ x − x || p ≤ ϵ 1 } and U ( x ) =
{ ˆ x | ||
ˆ x − x || q ≤ ϵ 2 } .
Define target threat model T =
S ∪ U .
Consider a linear feature extractor with bounded condition number: h ∈ { Wx + b | W ∈ R d × n , b ∈ R d , σ max ( W ) σ min ( W ) ≤ B < ∞} .
Then a valid expansion function is given by:
[Equation]
Proof.
By Lemma B.6 and Lemma B.4, V ( h, T ) ≤ s ( V ( h, S )) .
Additionally, it is clear that s p satisfies properties of expansion function.
Proof of Theorem 4.7.
Directly follows from Lemma B.5 and Lemma B.7.
B.4 How well can empirical expansion function predict loss on the target threat model for neural networks?
Using the empirical expansion function slopes from Figures 2 and 8, we compute the expected cross entropy loss (with softmax) on the target threat model via Corollary 4.4.
We provide the predicted and true target losses in Table 3 for ℓ ∞ , ϵ = 8255 source threat model and 4 for ℓ 2 , ϵ = 0 .
Target Source Variation Source Loss
[Table]
[Table]
In general
[Table]
we find that for models with smaller variation (those trained with variation regularization)
[Table]
the loss estimate using the slope from the expansion function generally improves.
In the case where the target threat model is Linf, we believe that the large gap between predicted and true loss for the unregularized model stems from the fact that we model the expansion function with a linear model.
From Figure 2, we can see that at larger values of source variation the linear model for expansion function becomes an increasingly loose upper-bound.
Improving the model for expansion function (ie.
using a log function) may reduce this gap.
C Additional Experimental Setup Details
Variation Computation Algorithm for AT-VR
We provide the algorithm we use to compute variation regularization for ℓ p source adversaries in Algorithm 1.
Algorithm
Input : x ∈ X , ℓ p radius ϵ , n number of steps, α step size, feature extractor
h
Notations :
U denotes the uniform distribution of dimension of the input, (cid:81) ℓ p ,ϵ denotes projection onto ℓ p ball of radius ϵ
Output : Variation v ∈ R 1 x
(cid:81)
U (
; // randomly initialize x
; // randomly initialize x i = 1 ...n do
// compute objective
// single step of PGD to optimize x ; // single step of PGD to optimize x
; // compute final variation v
Variation Computation for PAT-VR Laidlaw et al.
(2021) propose an algorithm called Fast
Lagrangian Perceptual Attack (Fast-LPA) to generate adversarial examples for training using PAT.
We make a slight modification of the Fast-LPA algorithm, replacing the loss in the original optimization objective with the variation objective, to obtain Fast Lagrange Perceptual Variation (Fast-LPV).
The explicit algorithm for Fast-LPV is provided in Algorithm 2.
We use the variation obtained from
Fast-LPV for training with PAT-VR.
Input label y , bound ϵ , number of steps n
Output : variation v 1 x 1 ← x + 0 .
01 ∗ N (0 . 1) ; // randomly initialize x2 x 2 ← x
01 ∗ N (0 . 1) ; // randomly initialize x i =
...n do
; // τ increases exponentially
|
−
||
2 − τ
(max(0 , d ( x 1 , x
− ϵ )
+ max(0 , d ( x 2 , x ) − ϵ ))
; // obj represents optimization objective
obj
∇ x
obj ] || 2 ;
// compute normalized gradient wrt
x
∇
obj obj
|| 2 ;
// compute normalized gradient wrt x
n ;
// step size η decays exponentially
// derivative of d in direction of ∆
m
d (
2 + 0 .
1∆ 2 ) /
// derivative of d in direction of ∆
( η/m )∆ 1 ;
// take a step of size η in LPIPS distance
( η/m
∆ 2 ;
// take a step of size η in LPIPS distance
[Table]
end
[Table]
return v
Additional Experimental Setup Details for AT-VR We run all training on a NVIDIA A100 GPU.
For all datasets and architectures, we perform PGD adversarial training (Madry et al., 2018) and add variation regularization to the objective.
For all datasets, train with normalized inputs.
On ImageNette, we normalize using ImageNet statistics and resize all images to 224 × 224 .
We train models on seed
0 for 200 epochs with SGD with initial learning rate of 0.1 and decrease the learning rate by a factor of 10 at the 100th and 150th epoch.
We use 10-step PGD and train with ℓ ∞ perturbations of radius 8255 and ℓ 2 perturbations with radius 0.5.
For ℓ ∞ perturbations we use step size of α = 2255 while for ℓ 2 perturbations we use step size of 0.075.
We use the same settings for computing the variation regularization term.
For all models, we evaluate performance at the epoch which achieves the highest robust accuracy on the test set.
Additional Experimental Setup Details for PAT-VR
We build off the official code repository for
PAT and train ResNet-50 models on CIFAR-10 with AlexNet-based LPIPS threat model with bound ϵ = 0 .
5 and ϵ = 1 .
For computing AlexNet-based LPIPS we use the CIFAR-10 AlexNet pretrained model provided in the PAT official code repository.
We train all models for 100 epochs and evaluate the model saved at the final epoch of training.
To match evaluation technique as Laidlaw et al.
(2021), we evaluate with ℓ ∞ attacks, ℓ 2 attacks, StAdv, and Recolor with perturbation bounds 8255 , 1, 0.05, 0.06 respectively.
Additionally, we present accuracy measured using AlexNet-based PPGD and LPA attacks (Laidlaw et al., 2021) with ϵ = 0 . 5 .
D Experiments for linear models on Gaussian data
In Section 4.3, we demonstrated that for a linear feature extractor, the expansion function exists, so decreasing variation across an ℓ p source adversarial constraint should improve generalization to other ℓ p constraints.
We now verify this experimentally by training a linear model for binary classification on isotropic Gaussian data.
D.1 Experimental Setup Data generation
We sample data from 2 isotropic Gaussians with covariance σ 2 I n where I n denotes the n × n identity matrix.
For class 0, we sample from a Gaussian with mean θ
=
25 , 0 , 0 , ..., 0) T , and for class 1, we sample from a Gaussian with mean θ 1 = (0 .
75 , 0 , 0 , ..., 0) T and clip all samples to range [0 , 1] to simulate image data.
We sample 1000 points per class.
We vary σ ∈ { 0 . 125 , 0 .
25 } and n ∈ { 25 , 100 } .
Since our generalization bound considers only threat model generalization gap and not sample generalization gap, we evaluate the models using the same data samples as used during training for the bulk of our experiments, but we provide results on a separate test set for one setting in Appendix D.5.
Model architecture
We train a model consisting of a linear feature extractor and linear top level classifier:
f = g ◦ h where h ( x ) =
Wx + b 1 where W ∈ R n × d , b 1 ∈ R d and g ( x ) =
Ax + bwhere A ∈ R d × 2 , b 2 ∈ R 2 .
For our experiments, we use d ∈ { 5 , 25 } .
Source Threat Models Across experiments we use 2 different source threat models: ℓ ∞ perturbations with radius 0 .
01 and ℓ 2 perturbations with radius 0.01.
Training Details
We perform AT-VR with adversarial examples generated using APGD (Croce &
Hein, 2020b) for 200 epochs.
We train models using SGD with learning rate of 0.1 and momentum of 0.9.
We use cross entropy loss during both training and evaluation.
For variation regularization, we use 10 steps for optimization and use step size ϵ/ 9 where ϵ is the radius of the ℓ p ball used during training/evaluation.
D.2 Visualizing the expansion function for Gaussian data
In Section 4.3, we demonstrated that with a linear feature extractor, for any dataset there exists a linear expansion function.
We now visualize the true expansion function for Gaussian data with a linear function class across 4 different combinations of input dimension n , Gaussian standard deviation σ , and feature dimension d .
We set our source threat model to be ℓ p , p ∈ {∞ , 2 } with perturbation size of 0 . 01 .
We set our target threat model to be ℓ p , p ∈ {∞ , 2 } perturbation size of 0 .
05 and compute source variation and target variation of 100 randomly sampled h .
We sample parameters of h from a standard normal distribution.
We plot the linear expansion function with minimum slope in Figure 3.
We find that across all settings we can find a linear expansion function that is a good fit.
Additionally, we find that the slope of this linear expansion function stays consistent across changes in σ and d .
We find that input dimension n can influence the expansion function which matches; for example, the slope of the expansion function for source ℓ 2 to target ℓ ∞ increases from ∼ 21 to 39 .
This matches our results in Lemma B.5 and Lemma B.7 where our computed expansion function depends on n .
[Figure]
a r i a t i
[Figure]
n
[Figure]
D.3 Generalization curves
We plot the threat model generalization curves for varied settings of input dimension n , feature extractor output dimension d , and Gaussian standard deviation σ in Figure 4.
We find that across all settings, applying variation regularization leads to smaller generalization gap across values of ℓ p radius ϵ .
D.4 Accuracies over regularization strength
We plot the accuracies corresponding to the n = 25 , σ = 0 .
125 and d = 5 setting in Figure 4 in
Figure 5.
We note that while Figure 4 demonstrated that regularization improves decreases the size of the generalization gap, there is trade-off in accuracy which can be seen at small of ϵ .
However, we find that generally variation regularization improves robust accuracy on unforeseen threat models.
D.5 Evaluations on a separate test set
We now plot generalization gap for the n = 25 , σ = 0 .
125 and d = 5 setting with cross entropy loss on the target threat model measured on a separate test set of 2000 samples in Figure 6.
We find that the trends we observed on the train set are consistent with those observed when evaluating on the train set shown in Figure 4.
E Additional Results for Logit Level AT-VR
In this section, we present additional results for AT-VR when considering the logits to be the output of the feature extractor h .
[Figure]
trained with varied variation regularization strength λ measured on adversarial examples of generated by target ℓ p , p = {∞ , 2 } perturbations with radius ϵ at varied input dimension n , feature extractor output dimension d and standard deviation σ .
The generalization gap is measured with respect to cross entropy loss.
All models are trained with source ℓ p , p = {∞ , 2 } radius of 0.01.
E.1 Results on Additional Seeds
In Table 5 we present the mean and standard deviations for robust accuracy of CIFAR-10 ResNetmodels over 3 trials seeded at 0, 1, and 2.
We find that the improvement observed through variation regularization on unforeseen target threat models is significant for both ℓ 2 and ℓ ∞ attacks for ResNet18 CIFAR-10 models; for bolded accuracies on target threat modes (with the exception of ℓ ∞ source to ℓ 2 target which we did not report as an improvement in the main text)
we find that the range of the error bars do not overlap with the results for standard adversarial training ( λ = 0 ).
Additionally, we find that the trade-off with clean accuracy observed when using variation regularization is also significant.
E.2 Expansion function on random features
In Section 5.6, we plotted the expansion function across models trained with adversarial training at various levels of variation regularization.
We now visualize the expansion function for random feature extractors to investigate to what extent the learning algorithm influences expansion function.
We plot the source and target variations (corresponding to the same setup as in Section 5.6) of 300 randomly
[Figure] [Figure]
initialized feature extractors of ResNet-18 on CIFAR-10 in Figure 7.
For random initialization, we use
Xavier normal initialization (Glorot & Bengio, 2010) for weights and standard normal initialization for biases.
[Figure]
target adversary ( ℓ ∞ and ℓ 2 respectively).
We find that with randomly initialized models, we can also find a linear expansion function with small slope.
In comparison to expansion functions from adversarially trained models (Figure 7), we find that using randomly initialized models leads to minimum linear expansion function s with smaller slope for ℓ ∞ target threat model.
This suggests that learning algorithm can have an impact on expansion function.
E.3 Expansion function between ℓ p and StAdv threat model
While we have shown that an expansion function with small slope exists between ℓ 2 and ℓ ∞ threat models, it is unclear whether this also holds for non- ℓ p threat models.
However, we do observe from
[Table]
Table 1 that AT-VR with ℓ 2 and ℓ ∞ sources leads to significant improvements in robust accuracy on
StAdv, which is a non- ℓ p threat model, suggesting that an expansion function between these threat models exists.
Using the same models for generating Figure 2, we plot the expansion function from ℓ ∞ and ℓ 2 sources to StAdv ( ϵ = 0 . 05 ) in Figure 8.
We observe that for both source threat models a linear expansion function exists to StAdv.
[Figure]
We now visualize the expansion function from StAdv ( ϵ = 0 .
03 ) source to ℓ ∞ ( ϵ = 8 / 255 ), ℓ( ϵ = 0 . 5 )
[Figure]
and StAdv ( ϵ = 0 .
target threat models.
We present plots in Figure 9.
Unlike our plots of expansion function for ℓ 2 and ℓ ∞ source threat models, we find that for StAdv a linear expansion function is not a tight upper bound on the true trend in source vs target variation.
A better model for expansion function would be piecewise linear function with 2 slopes, one for variation values nearand one for larger variation values since the slopes at points where source variation is closer to 0 is much larger than the slopes computed at points further from
[Figure]
[Figure]
E.4 Additional Results with ℓ p Target Threat Models
In Figure 1 of the main text, we plotted the unforeseen generalization gap and robust accuracies for
ResNet-18 models trained on CIFAR-10 with AT-VR at various perturbation size ϵ with ℓ ∞ source.
We plot the robust accuracy across ℓ p threat models for the models trained with standard adversarial training ( λ = 0 ) and with highest variation regularization strength used ( λ = 0 . 5 ) in Figure 10.
We find that at large values of ℓ p perturbation size, the model using variation regularization achieves higher robust accuracy than the model trained using standard adversarial training.
This improvement is most clear for ℓ ∞ targets.
We provide corresponding plots of unforeseen generalization gap and robust accuracy on CIFARon ℓ p target threat models for an ℓ 2 source in Figure 11.
Similar to trends with ℓ ∞ source threat model, we find that increasing the strength of variation regularization decreases the unforeseen generalization gap.
We find that with an ℓ 2 source threat model, the robust accuracy for the model trained with variation regularization also has consistently higher accuracy across target ℓ p threat models compared to the model trained with standard adversarial training ( λ = 0 )
[Figure]
E.5 Additional strengths of variation regularization
In Table 6 we present additional results for models trained at AT-VR at different strengths λ of variation regularization.
Overall, we find that models using variation regularization improve robustness on unforeseen attacks.
Generally, we find that union accuracies are also larger with higher strengths of variation regularization
[Table]
[Table] [Table]
E.6 Full AutoAttack results on CIFAR-
In Table
[Table]
we report the full AutoAttack evaluation of the ResNet-18 models trained on CIFARwith AT-VR with highest regularization strength displayed in in Table 13.
We find that robust accuracy is consistent across attack types, suggesting that variation regularization is not obfuscating gradients.
[Table]
E.7 Evaluations on other adversaries
In Table
[Table]
we present additional evaluations for ResNet-18 CIFAR-10 models on additional adversaries including Wasserstein adversarial attacks, JPEG attacks, elastic attacks, and perceptual attacks.
For Wasserstein adversarial attacks, we use PGD with dual projection (Wu et al., 2020b).
We use ℓ ∞
JPEG, ℓ 1 JPEG and elastic attacks from (Kang et al., 2019) and AlexNet LPIPS-based attacks (PPGD and LPA) from (Laidlaw et al., 2021) with perturbation size ϵ specified in Table 8.
Overall, we find that using variation regularization with ℓ p sources also improves performance on these additional adversaries.
This suggests that an expansion function exists between variation on ℓ p sources to more complicated threat models, including more perceptually-aligned threat models such as the bounded
AlexNet LPIPS distance used by PPGD and LPA attacks.
[Table]
E.8 Comparison to training with all attacks
In this section, we compare to the MAX adversarial training approach from Tramèr & Boneh (2019) which trains directly on all target threat models of interest.
Since MAX training uses information about the target threat model for training while our approach does not, the union accuracies achieved via MAX training should be viewed as an upper bound on performance.
For models using MAX training, we train for a total of 100 epochs and evaluate performance on the model saved at the final epoch.
We compare robust accuracies for MAX training to robust accuracies of models trained with variation regularization from Table 1.
For fair comparison, we report robust accuracies of models trained with variation regularization measured through evaluating on the target threat model (instead of the union of target with source threat model as in Table 1.
We provide results in Table 9.
We note that in general, training with the union of all attacks achieves more balanced accuracies across threat models.
The only exception is with WRN-28-10 for which MAX training achieves lower union accuracy and StAdv accuracy; however, this may be due to using only 100 epochs of training.
E.9 Combining variation regularization with TRADES
In the main paper, we provided experiments with variation regularization combined with PGD adversarial training (Madry et al., 2018) on ℓ ∞ and ℓ 2 source threat models.
We note that variation regularization is not exclusive to PGD adversarial training and can be applied in conjunction with other adversarial training based techniques including TRADES (Zhang et al., 2019).
We present results
[Table]
for TRADES-VR with TRADES hyperparameter β = 6 .
in Table 10.
Interestingly
[Table]
we find that compared to PGD adversarial training results in Table 1, TRADES generally has better performance on larger ℓ ∞ and ℓ 2 threat models (on par with AT-VR with PGD).
We find that across architectures and datasets applying variation regularization over TRADES adversarial training generally improves robustness on unforeseen ℓ ∞ and StAdv threat models, but trades off clean accuracy, source accuracy, and unforeseen ℓ 2 target accuracy.
Despite this trade-off, we find that TRADES-VR consistently improves on the accuracy across the union of all threat models in comparison to standard TRADES.
[Table]
E.10 Combining variation regularization with other sources
To demonstrate that variation regularization can be applied with source threat models outside of ℓ p balls, we evaluate the performance of AT-VR with other sources including StAdv and Recolor.
E.10.1 Computing variation with StAdv and Recolor sources
In StAdv (Xiao et al., 2018), adversarial examples are generated by optimizing for a per pixel flow field f , where f i corresponds to the displacement vector of the i th pixel of the image.
This flow field
[Table]
is obtained by solving:
[Equation]
where ℓ adv is the CW objective (Carlini & Wagner, 2017) and ℓ flow is a regularization term minimizing spatial transformation distance to ensure that the perturbation is imperceptible.
τ controls the strength of this regularization.
We adapt this objective to compute variation, replacing ℓ adv with the variation objective.
Rather than solving for a single flow field, we solve
[Equation]
Here f 1 ( x ) and f 2 ( x ) denote the perturbed input after applying f 1 and f 2 respectively and h denotes our feature extractor.
The second term ensures that both f 1 and f 2 have small spatial transformation distance.
We solve the optimization problem using PGD.
In Recolor attacks (Laidlaw & Feizi, 2019), the objective function takes the same form as Equationwhere f is now a color perturbation function.
We optimize for adversarial examples for Recolor in the same way as for StAdv, but incorporate an additional clipping step to ensure that perturbations of each color are within the specified bounds.
E.10.2 Experimental setup details for StAdv and Recolor sources
We train ResNet-18 models using AT-VR with StAdv and Recolor sources.
For these models, we train with source perturbation bound of 0.03 for StAdv and 0.04 for Recolor attacks.
We useiterations for both StAdv and Recolor during training.
We train for a maximum of 100 epochs and evaluate on the model saved at epoch achieving the highest source accuracy.
For evaluation, we use
StAdv perturbation bound of 0.05 and Recolor perturbation bound of 0.06 and use 100 iterations to generate adversarial examples for both attacks.
Additionally, we evaluate on ℓ ∞ and ℓ 2 attacks with radius 4255 and 0.5 respectively using AutoAttack.
E.10.3 Experimental Results for StAdv and Recolor sources
We report results in Table 11.
Similar to trends observed with ℓ p sources, we find that using variation regularization improves unforeseen robustness when using StAdv and Recolor sources.
For example, with StAdv source, using variation regularization with λ = 1 increases robust accuracy on unforeseen ℓ 2 attacks from 3.57% to 5.83%, and with Recolor source, using variation regularization with λ =increases robust accuracy on unforeseen ℓ 2 attacks from 3.07% to 20.03%.
The largest increase is for attacks of the same perturbation type but larger radius; for example, for StAdv source ( ϵ = 0 .
on unforeseen StAdv target ( ϵ = 0 . 05 ), the robust accuracy increases from 12.62% to 31.09%.
Similarily, for Recolor source ( ϵ = 0 . 04 ) on unforeseen Recolor target ( ϵ = 0 . 06 ), the robust accuracy increases from 21.75% to 66.02%.
Interestingly, we also find that using variation regularization with StAdv and
Recolor sources leads to a significant increase in source accuracy as well.
For StAdv, source accuracy increases from 54.04% without variation regularization to 62.78% with variation regularization at λ = 1 .
For Recolor source, this increase is even larger; source accuracy increases from 39.11% without variation regularization to 72.92% with variation regularization.
Further inspecting the source accuracy of the models trained Recolor source, we find that without variation regularization, the model overfits to the 10-iteration attack used during training.
When evaluated with 10-iteration Recolor, the standard adversarial training ( λ = 0 ) model achieves 86.62% robust accuracy, but when 100 iterations of the attack is used during testing, the model’s accuracy drops to 39.11%.
Interestingly, variation regularization helps prevent adversarial training from overfitting to the 10-iteration attack, causing the resulting source accuracy on the models with variation regularization to be significantly higher.
E.11 Computational complexity of AT-VR
One limitation of AT-VR is that it can be 3x as expensive compared to adversarial training.
This is because the computation for variation also requires gradient based optimization.
We note that this computational expense occurs when we use the same number of iterations of PGD for variation computation as standard adversarial training.
In this section, we study whether we can use fewer iterations of PGD for generating the adversarial example and computing variation.
We present our results for training ResNet-18 on CIFAR-10 with source threat model ℓ 2 , ϵ = 0 .
5 using AT-VR and standard AT ( λ = 0 ) in Table 12.
We find that even with a single iteration, AT-VR is able to significantly improve union accuracy over standard AT.
For ℓ ∞ adversarial training, we find that a
Union with Source λ
PGD
Clean
Source
[Table]
StAdv
Recolor
Union all iters acc acc ( ϵ = 12255 )
( ϵ = 1 )  89.
[Table]
single iteration of training does not work well due to the poor performance of adversarial training with FGSM.
F Additional Results for Feature Level AT-VR
In the main paper, we provide results for AT-VR with variation regularization applied at the layer of the logits.
In terms of our theory, this would correspond to considering the identity function to be the top level classifier.
In this section, we consider the top level classifier to be all fully connected layers at the end of the NN architectures used and evaluate variation regularization applied at the input into the fully connected classifier.
F.1 Expansion function for variation on features
In Figure 12, we plot the minimum linear expansion function computed on 315 adversarially trained feature extractors (analogous to Figure 2 in the main text).
Additionally, we plot the minimum linear expansion function on 300 randomly initialized feature extractors.
For random initialization, we use
Xavier normal initialization (Glorot & Bengio, 2010) for weights and standard normal initialization for biases.
We find that we can find a linear expansion function with small slope across ℓ ∞ and ℓsource and target pairs.
In comparison to expansion function for variation computed at the logits, we find that the slope of the expansion function s found is similar.
F.2 Additional results with ℓ p target threat models
We present the unforeseen generalization gap for ResNet-18 models on CIFAR-10 trained with source ℓ ∞ threat model with radius 8255 at various strengths of variation regularization and the corresponding
[Figure]
robust accuracy of the model trained with standard AT ( λ = 0 ) and highest variation regularization ( λ = 2 ) in Figure 13.
We find at large values of unforeseen ϵ , the model trained with variation regularization achieve both smaller unforeseen generalization gap and higher robust accuracy.
[Figure]
We repeat experiments with ResNet-18 models on CIFAR-10 trained with source ℓ 2 threat model with radius of 0.5.
We report the measured unforeseen generalization gap to ℓ ∞ , ℓ 2 , and ℓ 1 target threat models at different radii (measured via cross entropy loss on adversarial examples generated with APGD) along with corresponding robust accuracy of the no regularization and maximum regularization strength models in Figure 14.
We find that trends observed when the source threat model was ℓ ∞ are consistent with the trends for ℓ 2 source threat model: increasing the strength of variation regularization decreases the size of the unforeseen generalization gap and increases robust accuracy across various ℓ p target threat models.
[Figure]
F.3 Robust accuracies with feature level AT-VR
We repeat experiments corresponding to Table 1 in the main paper for models trained with feature level AT-VR in Table 13.
We observe similar trends with variation regularization applied at the features instead of logits: variation regularization improves unforeseen accuracy and generally improves source accuracy, but trades off performance on clean images
[Figure]
[Table] [Table]
[Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]