C ORR A TTACK : B LACK - BOX A DVERSARIAL A TTACK WITH S TRUCTURED S EARCH
Anonymous authors
Paper under double-blind review
A BSTRACT
We present a new method for score-based adversarial attack, where the attacker queries the loss-oracle of the target model.
Our method employs a parameterized search space with a structure that captures the relationship of the gradient of the loss function.
We show that searching over the structured space can be approximated by a time-varying contextual bandits problem, where the attacker takes feature of the associated arm to make modiﬁcations of the input and receives an immediate reward as the reduction of the loss function.
The time-varying contextual bandits problem can then be solved by a Bayesian optimization procedure which can take advantage of the features of the structured action space.
The experiments on
ImageNet and the Google Cloud Vision API demonstrate that the proposed method achieves the state of the art success rates and query efﬁciencies for both undefended and defended models
I NTRODUCTION
Although deep learning has many applications, it is known that neural networks are vulnerable to adversarial examples, which are small perturbations of inputs that can fool neural networks into making wrong predictions (Szegedy et al., 2014).
While adversarial noise can easily be found when the neural models are known (referred to as white-box attack ) (Kurakin et al., 2016).
However, in real world scenarios models are often unknown, this situation is referred to as black-box attack .
Some methods (Liu et al., 2016; Papernot et al., 2016) use the transfer-based attack, which generates adversarial examples on a substitute model and transfer the adversarial noise to the target model.
However, the transferability is limited and its effectiveness relies highly on the similarity between the networks (Huang & Zhang, 2020).
If two networks are very different, transfer-based methods will have low success rates.
In practice, most computer vision API such as the Google Cloud Vision API allow users to access the scores or probabilities of the classiﬁcation results.
Therefore, the attacker may query the black-box model and perform zeroth order optimization to ﬁnd an adversarial example without the knowledge of the target model.
Due to the availability of scores, this scenario is called score-based attack.
There have been a line of studies on black-box attack which directly estimate the gradient direction of the underlying model, and apply (stochastic) gradient descent to the input image (Ilyas et al., 2018; 2019;
Chen et al., 2017; Huang & Zhang, 2020; Tu et al., 2018; Li et al., 2019).
In this paper, we take another approach and formulate score-based attack as a time-varying contextual bandits problem.
At each state, the attacker may change the adversarial perturbation and get the reward as the reduction of the loss.
And the attacker would receive some features about the arms before making the decision.
By limiting the action space to image blocks, the associated bandits problem exhibits local correlation structures and the slow varying property suitable for learning.
Therefore, we may use the location and other features of the blocks to estimate the reward for the future selection of the actions.
Using the above insights, we propose a new method called CorrAttack, which utilizes the local correlation structure and the slow varying property of the underlying bandits problem.
CorrAttack uses Bayesian optimization with Gaussian process regression (Rasmussen, 2003) to model the correlation and select optimal actions.
A forgetting strategy is added to the algorithm so that the
Gaussian process regression can handle the time-varying changes.
CorrAttack can effectively ﬁnd blocks with the largest rewards.
The resulting method achieves much lower numbers of average queries and higher success rates than prior methods with a similar action space (Moon et al., 2019).
It is worth noting that BayesOpt (Ru et al., 2020) and Bayes-Attack (Shukla et al., 2019) also employ Bayesian optimization for score-based attack.
However, their Gaussian process regression directly models the loss as a function of the image, whose dimension can be more than one thousand.
Therefore, their speed is slow especially for BayesOpt, which uses slow additive kernel.
CorrAttack, on the other hand, searches over a much limited action space and models the reward as a function of the low dimensional feature.
Therefore, the optimization of CorrAttack is more efﬁcient, and the method is signiﬁcantly faster than BayesOpt.
We summarize the contributions of this work as follows:
We formulate the score-based adversarial attack as a time-varying contextual bandits, and show that the reward function has slow varying properties.
In our new formulation, the attacker could take advantage of the features to model the reward of the arms with learning techniques.
Compared to the traditional approach, the use of learning in the proposed framework greatly improves the efﬁciency of searching over optimal actions.
We propose a new method, CorrAttack, which uses Bayesian optimization with Gaussian process regression to learn the reward of each action, by using the feature of the arms.
The experiments show that CorrAttack achieves the state of the art performance on ImageNet and Google Cloud Vision API for both defended and undefended models.
R ELATED W ORK
There have been a line of works focusing on black-box adversarial attack.
Here, we give a brief review of various existing methods.
Transfer-Based Attack Transfer-based attack assumes the transferability of adversarial examples across different neural networks.
It starts with a substitute model that is in the same domain as the target model.
The adversaries can be easily generated on the white-box substitute model, and be transferred to attack the target model (Papernot et al., 2016).
The approach, however, depends highly on the similarity of the networks.
If two networks are distinct, the success rate of transferred attack would rapidly decrease (Huang & Zhang, 2020).
Besides, we may not access the data for training the substitute model in practice.
Score-based Attack Many approaches estimate the gradient with the output scores of the target network.
However, the high dimensionality of input images makes naive coordinate-wise search impossible as it requires millions of queries.
ZOO (Chen et al., 2017) is an early work of gradient estimation, which estimates the gradient of an image block and perform block-wise gradient descent.
NES (Wierstra et al., 2008) and CMA-ES (Hansen, 2016) are two evolution strategies that can perform query efﬁcient score-based attack Ilyas et al. Meunier et al.
Instead of the gradient itself, SignHunter (Al-Dujaili & O’Reilly, 2020a) just estimates the sign of gradient to reduce the complexity.
AutoZOOM (Tu et al., 2018) uses bilinear transformation or autoencoder to reduce the sampling space and accelerate the optimization process.
In the same spirit, data prior can be used to improve query efﬁciency (Ilyas et al., 2019).
Besides, MetaAttack (Du et al., 2020) takes a meta learning approach to learn gradient patterns from prior information, which reduces queries for attacking targeted model.
Many zeroth order optimization methods for black-box attacks rely on gradient estimation.
However, there are some research works using gradient free methods to perform black-box attack.
BayesOpt and Bayes-Attack (Ru et al., 2020; Shukla et al., 2019) employ Bayesian optimization to ﬁnd the adversarial examples.
They use Gaussian process regression on the embedding and apply bilinear transformation to resize the embedding to the size of image.
Although the bilinear transformation could alleviate the high dimensionality of images, the dimension of their embeddings are still in the thousands, which makes Bayesian optimization very ineffective and computationally expensive.
A different method, PARSI, poses the attack on (cid:96) ∞ norm as a discrete optimization problem over {− ε, ε } d (Moon et al., 2019).
It uses a Lazy-Greedy algorithm to search over the space {− ε, ε } d to ﬁnd an adversarial example.
SimBA (Guo et al., 2018) also employs a discrete search space targeted at (cid:96) 2 norm.
Decision-based Attack Decision-based attack assumes the attacker could only get the output label of the model.
Boundary Attack and its variants (Brendel et al., 2017; Chen et al., 2020; Li et al., 2020) are designed for the setting.
However, the information received by the attacker is much smaller than score-based attack, and it would take many more queries than score-based attack to successfully attack an image.
P RELIMINARIES
A Gaussian process (Rasmussen, 2003) is a prior distribution deﬁned on some bounded set Z , and is determined by a mean function µ : Z → R and a covariance kernel κ : Z × Z → R .
Given n observations D n = { ( z i , f ( z i )) } ni =1 , the prior distribution on f ( z 1: n ) is
[Equation]
where we use compact notation for functions applied to collections of input points:
z 1: n indicates the sequence z 1 , · · · , z n , f
[Equation]
z
[Equation]
Now we wish to infer the value of f ( z ) at some new point z , the posterior process f ( z ) |D n is also a
Gaussian process (GP) with mean µ n and covariance σ 2 n :
[Equation]
As a optimization method to maximize a function f , Bayesian optimization models the function to make decisions about where to evaluate the next point z .
Assuming we already obtained observations
D t − 1 =
( z i , f ( z i ))
} t − 1 i =1 , to determine the next point z t for evaluation, we ﬁrst use the posterior GP to deﬁne an acquisition function ϕ t : Z → R , which models the utility of evaluating f ( z ) for any z ∈ Z .
We then evaluate f ( z t ) with
[Equation]
In this work, we use the expected improvement (EI) acquisition function (Mockus et al., 1978)
[Equation]
with γ ( z
[Equation]
=
[Equation]
which measures the expected improvement over the current best value z best
= arg max z i f ( z i ) according to the posterior GP.
Here Φ( · ) and φ ( · ) are the cdf and pdf of N (0 , I ) respectively.
S CORE - BASED B LACK - BOX A TTACK
Suppose a classiﬁer F ( x ) has input x and label y .
An un-targeted adversarial example x adv satisﬁes:
[Equation]
and
[Equation] [Equation]
where C is the number of classes.
While an adversarial example for targeted attack means the maximum position of F ( x ) should be the targeted class q : arg max j ∈{ 1 , ··· C } F ( x adv )
j = q .
In order to ﬁnd x adv , we may optimize a surrogate loss function (cid:96) ( x, y )
(e.g hinge loss).
In this work, we consider adversarial attack as a time-varying contextual bandits problem.
At each time t , we observe a state x t which is a modiﬁcation of the original input x 0 .
Before taking arm a t ∈
A ⊂ R d , we could observe the feature z of arms.
And a t would modify state x t to x t + according to
[Equation]
with reward function r ( x t , a t ) =
(cid:96) ( x t +1 , y ) − (cid:96) ( x t , y ) and the checking step tries to remove negative reward.
In this frame, we would like to estimate the reward r ( x t , a t ) with feature z t using learning, and then pick a t to maximize the reward.
Observe that
[Equation] [Equation]
where the gradient ∇ x t (cid:96) ( x t , y ) is unknown.
It follows from the formulation that we may rewrite r ( x t , a t ) as a function
[Equation]
Since in general, we make small steps from one iteration to the next iteration, δ t ( a t ) =
x t +1 − x t is small.
We may approximate the reward with ﬁxed gradient locally with
[Equation]
We may consider the learning of reward as a time-varying contextual bandits problem with reward function ˜ f t ( a t ) for arm a t at time t .
Since x t +1 − x t is small, this time-varying bandits has slowvarying property: the function ˜ f t changes slowly from time t to time t + 1 .
In the proposed framework, our goal is to learn the time-varying bandits reward ˜ f t ( a t ) with feature z t .
We use Gaussian process regression to model the reward function using recent historic data since the reward function is slow-varying, and describe the details in the subsequent sections.
We note that the most general action space contains all a t ∈ R d , where d is the number of image pixels.
However, it is impossible to explore the arms in such a large space.
In this work, we choose a speciﬁc class of actions
A = { a i } ni
=1 , n is the image blocks of different sizes.
It covers the space of the adversarial perturbations while maintaining good complexity.
We also ﬁnd the location and the PCA of the blocks a good component of the feature z associated with the arm.
Besides, modifying a block only affects the state locally.
Therefore the reward function remains similar after state changes.
4. S TRUCTURED S EARCH WITH G AUSSIAN P ROCESS R EGRESSION AND B AYESIAN O PTIMIZATION
Deﬁne the block size as b , we divide the image into several blocks E = { e 000 , e 001 , · · · , e hwc } , where the block is b × b square of pixels and ( h, w, c )
= ( height /b, width /b, channel ) .
Each block e ijk is associated with the feature z e ijk such as the location of the block.
Suppose we have time-varying bandits with state x t and unknown reward function ˜ f t at time t .
By taking the action a e ijk , we change the individual block e ijk of x t and get x t +1 with reward ˜
f t ( a e ijk ) .
We consider two ways of taking action a e ijk on block e ijk : CorrAttack Diff and CorrAttack Flip .
Finite Difference CorrAttack Diff : For action a e ijk , the attacker will query (cid:96) ( x t + ηe ijk , y ) and (cid:96) ( x t − ηe ijk , y ) , and choose
[Equation]
The action space A =
{ a e ijk | e ijk ∈ E } .
In our framework, the bandits problem can also be regarded as learning the conditional gradient over actions.
That is, when η is small, we try to choose action a t with
[Equation] [Equation]
which is the conditional gradient over the set of blocks.
Discrete Approximation CorrAttack Flip :
In general, adversarial attack with (cid:96) ∞ budget can be formulated as constrained optimization with (cid:107) x adv − x (cid:107) ∞ ≤ (cid:15) .
However, PARSI (Moon et al., 2019) limits the space to {− ε, + ε } d , which leads to better performance for black-box attack (Moon et al., 2019).
The continuous optimization problem becomes a discrete optimization problems as follows:
[Equation]
subject to
[Equation]
subject to x adv − x ∈ { (cid:15), − (cid:15) } d .
Following PARSI, we consider two stages to perform structured search.
When ﬂipping ε to − ε , a e ijk changes the block to − ε and A = {− 2 εe ijk | e ijk ∈ E } .
When changing − ε to ε , A = { 2 εe ijk | e ijk ∈ E } instead.
Gaussian Process (GP) Regression:
We model the difference function
[Equation]
instead of the reward function ˜ f t ( a t ) ≥ 0 , as the difference function could be negative, providing more information about the negative arms in A .
We would collect historic actions with feature and difference { z k , g k ( a k )) } tk =1 and learn the difference to make choices at a later stage.
At each time t , we use the Gaussian process regression to model the correlation between the features z e ijk and use
Bayesian optimization to select the next action.
More speciﬁcally, the same as eq.
(2), we let
[Equation]
12) where D t = { z k , g k ( a k )) } tk = t − τ is the difference of evaluated blocks e t − τ : t with feature z e t − τ : t and τ is a parameter to forget old samples.
Then we use EI acquisition function to pick up the next action a t +1 in A .
More speciﬁcally, the same as eq.
(4), we let
[Equation]
As the difference function g t is varying, we take two strategies in Algorithm 2 to update the previous samples to make sure GP regression learns the current difference function well.
The ﬁrst strategy is to remove old samples in D t .
Even if the bandits are slowly varying, the difference function will change signiﬁcantly after a signiﬁcant number of rounds.
Therefore, we need to forget samples before t − τ .
The second strategy is to remove samples near the last block e i t j t k t in D t .
As we discuss later, the difference function may change signiﬁcantly in a local region near the last selected block.
Therefore previous samples in this local region will be inaccurate.
The resulting algorithm for CorrAttack is shown in Algorithm 1, which mainly follows standard procedure of Bayesian optimization.
Algorithm
Require: Loss function (cid:96) ( · , · ) , Input x 0 and its label y , Action space
A = { a e ijk | e ijk ∈ E
, Parameter c , τ , α 1: Build set D
= { ( z e ipjpkp , g 0 ( a e ipjpkp )) } mp =
1 using latin hypercube sampling from A 2: repeat 3:
Fit the parameter of Normal ( µ t ( z e ijk ) , σ 2 t ( z e ijk )) on D t according to Equation (12) 4:
Calculate acquisition function ϕ t ( z e ijk ) and according to Equation (13) 5:
Select a e itjtkt = arg max A ϕ t ( z e ijk ) according to Equation (13) 6: x t +1 =
arg min s ∈{ x t + a eitjtkt ,x t } (cid:96) (Π B p ( x,ε ) ( s ) , y ) 7:
Update sample set D t with Algorithm 2 D t +
=
U PDATE S AMPLES
( D t , x t , x t +1 , e i t j t k t , g t +1 ( a e itjtkt ) , τ, α ) 8: until max A ϕ t ( z e ijk ) <
c 9: return x T ;
Require:
Sample set D t , State x t , x t +1 , Block e i t j t k t , Difference g t +1 ( a e itjtkt ) , Paramter τ , α 1:
if x t +1 (cid:54) =
x t then 2:
D t +1 =
D t \ { ( z e ijk , g ) ∈
D t
|| i − i t | + | j − j t | ≤ α } 3: else 4:
D t +1 =
D t ∪ { ( z e itjtkt , g t +1 ( a e itjtkt )) } 5: end if 6: Remove the earliest
>
7: return D
4. F EATURES AND S LOW V ARYING P ROPERTY
Features of Contextual Bandits: We use a four dimensional vector as the feature z e ijk :
[Equation]
[Equation]
where i, j, k is the location of the block.
And pca is the ﬁrst component of PCA decomposition of [ x 0 ( e 000 ) , x 0 ( e 001 ) , · · · x 0 ( e hwc )] .
x 0 ( e ijk ) means the block of natural image at the given position.
The reward function depends on the gradient in Equation (7).
It has been shown that the gradient ∇ x (cid:96) ( x, y ) has local dependencies (Ilyas et al., 2019).
Suppose two coordinates e ijk and e lpq are close, then ∇ x (cid:96) ( x, y ) ijk ≈ ∇ x (cid:96) ( x, y ) lpq .
We consider the ﬁnite difference of the block e ijk
[Equation]
where η is a small step size.
When η is small, the reward can be approximated by the average of the gradients around a small region, which also has local dependencies.
In fact, the local structure of the reward will also be persevered when the block size and η is large.
Figure 1 shows one example of the ﬁnite difference ∆ t ( e ijk ) obtained on ImageNet dataset with ResNet50.
This shows blocks with closer locations are more likely to have similar reward.
Therefore, we add the location of the block as the feature so that it uses historic data to ﬁnd the arm with the largest reward.
In addition to the location of the difference, we may add other features.
The block of the image itself forms a strong feature for the regression, but the dimension of the block is too high for GP regression.
Therefore, we use PCA to lower the dimension and add the ﬁrst component into the feature vector.
Slow Varying Property
In addition to the local dependencies of ﬁnite difference, the difference would also be slow varying if we just change a small region of x t .
Let x
t
+
=
x
t − ηe i t
j t k t , Figureshows the difference of ∆ t ( e ijk ) and ∆ t +1 ( e ijk ) , which is centralized in a small region near e i t j t k t .
Reward function is based on the ﬁnite difference, which also has the slow varying property.
It could be explained by the local property of convolution.
When η is small, the ﬁnite difference can be approximated with gradient and the local Hessian:
[Equation]
The difference is much smaller than ∆ t ( e ijk ) .
Today’s neural networks are built with stacks of convolutions and non-linear operations.
Since these operations are localized in a small region, the
Hessian of a neural network is also localized and the reward function only changes near e i t
j t k t .
4. H IERARCHICAL B AYESIAN O PTIMIZATION S EARCH
Recent black-box approaches (Chen et al., 2017; Moon et al., 2019) exploit the hierarchical image structure for query efﬁciency.
Following these approaches, we take a hierarchical approach and perform the accelerated local search in Algorithm 1 from a coarse grid (large blocks) to a ﬁne grid (smaller blocks).
The algorithm for hierarchical attack iteratively performs Algorithm 1 at one block size, and then divides the blocks into smaller sizes.
At each block size, we build a
Gaussian process to model the difference function, and perform structured search with the blocks until max A ϕ t ( z e ijk ) < c .
When dividing the blocks into smaller sizes, we will build a new block set E with action a e ijk and new feature z e ijk , but keep the x t in last block size as x 0 in new block size.
Deﬁne the stage as S = { 0 , 1 , · · · , s } and initial block size as b .
The block at stage s is b 2 s × b 2 s square of pixels and ( h, w, c ) =
(2 s ∗ height /b, 2 s ∗ width /b, channel ) .
The overall hierarchical accelerated local search algorithm is shown in Appendix A.
It is important to note that most of the attacks terminate in the early stages and rarely need to run on ﬁne scales.
ε = 0 .
Since BayesOpt and Bayes-Attack needs thousands of hours to run all samples, we only test 20 samples, which are marked as *, the complexity and running time could be referred to C.6.
[Table] [Table]
E XPERIMENTS
We evaluated the number of queries versus the success rates of CorrAttack on both undefended and defended network on ImageNet (Russakovsky et al., 2015).
Moreover, we attacked Google Cloud
Vision API to show that CorrAttack can generalize to a true black-box model.
We used the common hinge loss proposed in the CW attack (Carlini & Wagner, 2017).
We compared two versions of CorrAttack :
CorrAttack Diff and CorrAttack Flip , to ZOO (Chen et al., 2017), NES (Ilyas et al., 2018), NAttack (Li et al., 2019), Bandits (Ilyas et al., 2019), PARSI (Moon et al., 2019),
Square Attack (Andriushchenko et al., 2020), SignHunter(Al-Dujaili & O’Reilly, 2020b), BayesOpt (Ru et al., 2020) and Bayes-Attack (Shukla et al., 2019).
We only test adversarial attack on (cid:96) ∞ norm.
The details of the Gaussian processes regression and the hyperparameters of CorrAttack are given in the Appendix B. We shall mention that CorrAttack is not sensitive to the hyperparameters.
The hyperparameters of other methods follow those suggested by the original papers.
5. U NDEFENDED N ETWORK
We randomly select 1000 images from the validation set of ImageNet and only attack correctly classiﬁed images.
The query efﬁciency of CorrAttack is tested on VGG16 (Simonyan & Zisserman, 2014),
Resnet50 (He et al., 2016) and Densenet121 (Huang et al., 2017), which are the most commonly used network structures.
We set ε = 0 .
05 and the query limit to be 10000 except for BayesOpt and
Bayes-Attack.
For targeted attacks, we randomly choose the target class for each image and the target classes are maintained the same for the evaluation of different algorithms.
The results are shown in
Table 1 and 2.
CorrAttack Flip outperforms other methods by a large margin. [Table]
[Table] As BayesOpt and Bayes-Attack takes tens of thousands of hours to attack 1000 images [Table] we compare them with CorrAttack Flip only on 20 images and un-targeted attack.
The query limit is also reduced to 1000 as the time for BayesOpt and Bayes-Attack quickly increases as more samples add into the
Gaussian distribution.
The time comparison between three models is shown in Appendix C.6.
Optimality of Bayesian optimization Appendix C.1 shows the rank the actions found by CorrAttack.
The attacker could ﬁnd the action with large reward quickly.
Varying ε
We also test the algorithms at different budget of adversarial perturbations at ε = 0 .and
ε = 0 .
06 on Resnet50.
As it is shown in Appendix C.2, CorrAttack shows a consistently better performance at different ε .
Ablation study on random choices Appendix C.3 shows the ablation study of random version of
CorrAttack Diff and CorrAttack Flip .
In both cases, Bayesian optimization helps to gain better query efﬁciency.
Ablation study on hierarchical attack We perform ablation study on the hierarchical attack and the result is shown in Appendix C.4.
Hierarchical structure accelerates the CorrAttack and eliminates the sensitivity of choosing initial block size.
Ablation study on features Appendix C.5 demonstrates how the feature of the contextual bandits affects the performance of attack.
PCA would help to improve the efﬁciency of attack.
5. D EFENDED N ETWORK
To evaluate the effectiveness of CorrAttack on adversarially defended networks, we tested our method on one of the SOTA robust model (Xie et al., 2018) on ImageNet.
The weight is downloaded from
Github 1 . "
ResneXt DenoiseAll" is chosen as the target model as it achieves the best performance.
We set ε = 0 .
and the maximum number of queries is 10000.
As BayesOpt runs very slowly, the attack is also performed on 10 images and the query limit is 1000.
The result is shown in Table 3.
CorrAttack Flip still outperforms other methods.
5. G OOGLE C LOUD V ISION API
We also attacked Google Cloud Vision API, a real world black-box model for classiﬁcation.
The target is to remove the top-1 label out of the classiﬁcation output.
We choose 10 images for the
ImageNet dataset and set the query limit to be 500 due to high cost to use the API.
We compare
CorrAttack Flip with NAttack, BayesOpt and PARSI.
The result is shown in Table 4.
We also show one example of the classiﬁcation output in Appendix C.
C ONCLUSION AND F UTURE W ORK
We formulate the score-based adversarial attack as a time-varying contextual bandits and propose a new method CorrAttack.
By performing structured search on the blocks of the image, the bandits has the slow varying property.
CorrAttack takes advantage of the the features of the arm, and uses
Bayesian optimization with Gaussian process regression to learn the reward function.
The experiment shows that CorrAttack can quickly ﬁnd the action with large reward and CorrAttack achieves superior query efﬁciency and success rate on ImageNet and Google Cloud Vision API.
We only include basic features for learning the bandits.
Other features like embedding from the transfer-based attack Huang & Zhang (2020) may be taken into account in the future work.
While our work only focuses on adversarial attack on (cid:96) ∞ norm, the same contextual bandits formulation could be generalized to other (cid:96) p norm to improve query efﬁciency.
Besides, defense against CorrAttack may be achieved with adversarial training on CorrAttack , but it may not be able to defend other attacks in the meantime.
A A LGORITHM Algorithm
Require: Set of blocks E , Block size b , E (cid:48)
= ∅ 1: for each block e ∈ E do 2:
Split the block e into 4 blocks { e 1 , e 2 , e 3 , e 4 } with size b/ 2 3:
E (cid:48) ← E (cid:48) ∪ { e 1 , e 2 , e 3 , e 4 } 4: end for 5: return E (cid:48) ;
Require: Loss function (cid:96) ( · , · ) , Input image x and its label y , Initial Block size b , Set of blocks E containing all blocks of the image, Threshold c , τ , α , Step size η , Adversarial budget ε 1: x 0 = x 2: repeat 3:
Choose A
= { a e ijk | e ijk ∈ E } with Equation (8) 4:
Run CorrAttack on current block size x =
C ORR
A TTACK ( (cid:96) ( · , · ) , x, y, A, c, τ, α ) 5: if b > 1 then 6:
Split the blocks into ﬁner blocks using Algorithm 3 E = S PLIT B LOCK ( E, b ) 7: b ← b/8: end if 9: until (cid:96) converges 10: return x K ;
Require: Loss function (cid:96) ( · , · ) , Input image x and its label y , Block size b , Set of blocks E containing all blocks of the image, Threshold c , τ , α , Adversarial budget ε 1: x 0 = x 2: for e ijk ∈ E do 3:
Randomly draw v from {− ε, ε } 4: x 0 [ e ijk ] = v + x 0 [ e ijk ] 5: end for 6: repeat 7:
A n =
[Equation]
(cid:62)
[Equation]
( x k
[Equation]
x ) < 0 } 8:
Run CorrAttack ﬂipping − ε to ε ˜ x
[Equation]
=
C ORR A TTACK ( (cid:96) ( · ,
[Equation] [Equation]
, y, A n , c, τ, α ) 9: A
[Equation]
(cid:62)
[Equation]
x ) > 0 } 10:
Run CorrAttack ﬂipping ε to − ε x
[Equation]
ORR
[Equation]
TTACK ( (cid:96)
[Equation] [Equation]
, y,
[Equation]
p , c,
[Equation]
, α ) 11: if b > 1 then 12:
Split the blocks into ﬁner blocks using Algorithm 3 E = S PLIT B LOCK ( E, b ) 13: b ← b/14: end if 15: until (cid:96) converges 16: return x K ;
B D ETAILS OF E XPERIMENT S ETTING
We use the hinge loss for all the experiments.
For un-targeted attacks,
[Equation]
17) and for targeted attacks,
[Equation] [Equation]
Here F represents the logits of the network outputs, t is the target class, and ω denotes the margin.
The image will be projected into the ε -ball.
Besides, the value of the image will be clipped to range [0 , 1] .
B. G AUSSIAN P ROCESS R EGRESSION AND B YAESIAN O PTIMIZATION
We further provide details on both the computational scaling and modeling setup for the GP regression.
To address computational issues, we use GPyTorch (Gardner et al., 2018) for scalable GP regression.
GPyTorch follows (Dong et al., 2017) to solve linear systems using the conjugate gradient (CG) method and approximates the log-determinant via the Lanczos process.
Without GPyTorch , running
BO with a GP regression for more than a few thousand evaluations would be infeasible as classical approaches to GP regression scale cubically in the number of data points.
On the modeling side, the GP is parameterized using a Matérn- 5 / 2 kernel with ARD and a constant mean function for all experiments.
The GP hyperparameters are ﬁtted before proposing a new batch by optimizing the log-marginal likelihood.
The domain is rescaled to [0 , 1] d and the function values are standardized before ﬁtting the GP regression.
We use a Matérn- 5 / 2 kernel with ARD for
CorrAttack and use the following bounds for the hyperparameters: (length scale) λ i ∈ [0 . 005 , 2 . 0 ] , (output scale) λ (cid:48) i ∈ [0 . 05 , 20 . 0] , (noise variance) σ 2 ∈ [0 . 0005 , 0 . 1] .
B. H YPERPARAMETERS
For CorrAttack in Algorithm 4 and Algorithm 5, we set the initial block size b to be 32 and the step size η for CorrAttack Diff is 0.03.
In Algorithm 1, we use the initial sampling ratio m = 0 .
03 n at the start point for Gaussian process regression, the threshold c = 10 − 4 to decide when to stop the search of current block size.
In Algorithm 2, the threshold is different for different block size.
For
CorrAttack Flip , α = 1 , 1 , 2 , 2 , 3 for block size 32, 16, 8, 4, 2 and for CorrAttack Diff , α = 0 , 0 , 1 , 1 ,for block size 32, 16, 8, 4, 2.
We set τ = 3 m = 0 .
09 n to remove the earliest samples from D once | D | > α .
The Adam optimizer is used to optimize the mean µ and covariance κ of Gaussian process, where the iteration is 1 and the learning rate is 0.1.
For PARSI, the block size is set to 32 as CorrAttack , other hyperparameters are the same as the original paper.
For Bandits, Bayes-Attack and BayesOpt, the hyperparameters are the same as the original paper.
We optimize the hyperparameters for ZOO, NES.
For un-targeted attack on NES, we set the sample size to be 50, learning rate to be 0.1.
For targeted attack on NES, the sample size is also 50 and the learning rate is 0.05.
The learning is decay by 50% if the loss doesn’t decrease for 20 iterations.
For NAttack, we set the hyperparameters the same as NES and add momentum and learning rate decay, which are not mentioned in the original paper.
For ZOO, we set the learning rate to 1.0 and sample size to be 50.
Other setting follows the original paper.
C A DDITIONAL E XPERIMENTS C. O PTIMALITY OF B AYESIAN O PTIMIZATION
Figure 3 shows the reward function that the Bayesian optimization could ﬁnd in the action set.
CorrAttack could ﬁnd the action with high reward within just a few queries.
It shows that the
Gaussian process regression could model the correlation of the reward function and the Bayesian optimization could use it to optimize the time-varying contextual bandits.
C. V ARYING THE A DVERSARIAL B UDGET
We test CorrAttack on different adversarial budget on ImageNet for both un-targeted attack and targeted attack.
Table 5 and Table 6 show the success rate and average queries for ε = 0 .
[Table]
[Figure] [Table] [Table]
[Table]
C. A BLATION S TUDY ON R ANDOM C HOICES
Table 7 and Table 8 show the ablation study on the strategy to choose action x t +1 in the line 6 of Algorithm 1. The process of Bayesian optimization helps to accelerate the optimization. As targeted attack is more complicated and requires larger number of queries, CorrAttack has more advantage in this scenario.
C. A BLATION S TUDY ON H IERARCHICAL A TTACK
We perform un-targeted attack on Resnet50 as shown in Table 10. Hierarchical attack lowers the average queries and improves the query efﬁciency. Besides, hierarchical attack avoids the problem of choosing block size. As shown in Table 10, block size for non-hierarchical is essential for the performance.
C. A BLATION S TUDY ON F EATURES
Table 11 shows the success rate and average queries for CorrAttackwith different features.
We perform ablation study on the features of the contextual bandits.
One contains just the location of the
[Table]
[Table] [Table] [Table] block and the other contains both the location and the PCA feature.
PCA helps the learning process of the reward and achieve higher success rate and lower number of queries.
PCA feature achieves signiﬁcant improvement on CorrAttack Flip .
We may ﬁnd more useful features in the future.
C. C OMPARISON BETWEEN C ORR A TTACK F LIP , B AYES O PT AND B AYES -A TTACK
The main difference between BayesOpt and Bayes-Attack is using different types of GP regression (Standard GP for Bayes-Attack and Additive GP for BayesOpt), so we will consider these two models as a group when comparing with our model CorrAttack.
Difference between CorrAttack, BayesOpt and Bayes-Attack: For l ∞ attacks, assume there are no hierarchical structure, we have blocks E
= { e 000 , e 001 , · · · , e hwc } , where the block is b × b square of pixels and ( h, w, c ) =
( height /b, width /b, channel ) .
CorrAttack, BayesOpt (Ru et al., 2020) and
Bayes-Attack (Shukla et al., 2019) all try to search the adversarial noise on E with perturbation δ ∈ [ − (cid:15), (cid:15) ] d where d = h × w × c , the perturbation of block e ijk at time t is δ te ijk . BayesOpt and Bayes-Attack use a GP regression directly on δ ∈ [ − (cid:15), (cid:15) ]
d (all blocks),
[Equation]
CorrAttack deﬁne an action space A and use a standard GP regression on features z e ijk =
( i, j, k, pca ) (single block),
[Equation]
( µ t ( z e ijk ) , σ 2 t ( z e ijk )) .
[Table]
[Table]
At each iteration
[Table]
in BayesOpt and Bayes-Attack
[Table]
the changes of overall perturbation is
[Equation] However, in CorrAttack, [Equation] In conclusion
[Table]
BayesOpt and Bayes-Attack view each block as a dimension, try to search the overall perturbation directly.
CorrAttack deﬁnes a low dimension feature space, keep an overall perturbation and try to search an action on single block
[Table]
Time complexity and running time: The time complexity of ﬁtting GP regression is O ( dn 2 ) where d is the dimension of input and n is the number of samples. And the dimension for CorrAttack ( d = 4 for z e ijk = ( i, j, k, pca ) ) is much smaller than BayesOpt and Bayes-Attack ( d = 6912 if h = w = 48 , c = 3 ).
Moreover, we can convert the continuous search space of BayesOpt and
Bayes-Attack from [ − (cid:15), (cid:15) ] 6912 to discrete search space E
= { e 000 , e 001 , · · · , e hwc } , whose number is only 6912, smaller search space could save the computation time of acquisition function.
We compare the running time for CorrAttack Flip with BayesOpt and Bayes-Attack on 20 images from ImageNet.
Table 12 shows the running time for the un-targeted attack.
We use PyTorchto develop these two models.
All experiments were conducted on a personal workstation with
Intel(R) Xeon(R)
Gold 5120 2.20GHz CPUs, an NVIDIA GeForce RTX2080Ti 11GB GPU and 252G memory.
BayesOpt models the loss function with a very high dimensional Gaussian process.
The decomposition of additive kernel also needs to be restarted several times.
Even though we try to optimize the speed of BayesOpt with GPU acceleration, it is still very slow and takes hundreds of times more computational resources than CorrAttack .
Bayes-Attack could be regarded as a simpler version of BayesOpt, which does not add additive kernel.
We do not evaluate it on targeted task (when query>1000)
since GP inference time grows fast as evaluated query increases, e.g. For Bayes-Attack, when 150 < query < 200 , Time= 1 . 6 s/query ; 800 < query < 1000 , Time = 10 .
5 s/query .
CorrAttack solves this problem with Time= 0 .
1 s/query even when query reaches 10000.
Since we forget the previous samples before t − τ , our input sample n will be smaller than τ .
The forgetting technique can not be applied into the Bayes-Attack and BayesOpt since they are searching the perturbation of all blocks so each sample needs to be remembered.
C. G ROWING CURVE OF SUCCESS RATE
The number of average queries is sometimes misleading due to the the heavy tail distribution of queries.
Therefore in Figure 4, we plot the success rates at different query levels to show the detailed behaviors of different attacks.
It shows that CorrAttack is much more efﬁcient than other methods at all query levels. [Table] [Figure] [Table]
[Figure]
[Table]
[Figure] [Table] [Figure] [Table]
[Figure]
[Table]
[Figure]
Figure 5 shows more examples of ﬁnite difference for different network architectures and different dataset. They all have local correlation structure as shown in Figure 1. And Figure 6 shows more examples like Figure 2, the slow varying properties exist for different architectures and different datasets.
C. G OOGLE C LOUD V ISION API
Figure 7 shows the example of attacking the Google Cloud Vision API.
CorrAttack Flip and PARSI successfully change the classiﬁcation result.
BeyesOpt, however, can not remove the top 1 classiﬁcation result out of the output
. C. V ISUALIZATION OF A DVERSARIAL E XAMPLES
[Figure]
[Figure]
[Figure]