Explaining and Harnessing Adversarial Examples

  2019-7-30 


《Explaining and Harnessing Adversarial Examples》
Ian J. Goodfellow, Jonathon Shlens & Christian Szegedy
ICLR 2015

为什么会产生对抗样本?

以前的观点: extreme nonlinearity of DNN and insufficient model averaging and insufficient regularization of the purely supervised learning problem

本文的观点:Linear behavior in high-dimensional spaces is sufficient to cause adversarial examples

  1. Box-constrained L-BFGS can reliably find adversarial examples.

  2. On some datasets, such as ImageNet (Deng et al., 2009), the adversarial examples were so close to the original examples that the differences were indistinguishable to the human eye.

  3. The same adversarial example is often misclassified by avariety of classifiers with different architectures or trained on different subsets of the training data.

  4. Shallow softmax regression models are also vulnerable to adversarial examples.

  5. Training on adversarial examples can regularize the model —however , this was not practical at the time due to the need for expensive constrained optimization in the inner loop

这就引起我们怀疑即便当前最好的模型是否只是虚有其表,并没有真正学习到内在的语义信息。仅仅能够fit现有样本,无法泛化。

对抗样本的线性解释

本文提出了对对抗样本产生原因的线性解释.设置扰动$\eta,\epsilon$为一个小到可以被分类器忽略的值

$\hat{x} = x+\eta$ ,若$||\eta||_\infty<\epsilon$,分类器将无法将$x$与$\hat{x}$分开

则$w^T\hat{x}=w^T(x+\eta)=w^Tx+w^T\eta$

若维度很高,则即使$\eta$很小,也会使得$w^T\eta$非常大,影响分类器的判断

令$\eta=sign(w)$即可使得$w^T\eta$最大

非线性模型的线性扰动

对于现在的神经网络都有很强的线性性质以至于无法抵抗对抗攻击,如 LSTMs (Hochreiter & Schmidhuber, 1997), ReLUs (Jarrett et al., 2009; Glorot et al., 2011), maxout networks (Goodfellow et al., 2013c) 都设计得具有很强的线性性质,所以也方便优化。FGSM将损失函数近似线性化,从而获取$||\eta||_\infty<\epsilon$的最优扰动。

Fast Gradient Sign Method(FGSM)

注意这里$y=y_{true}$

通过实验证明,作者的假设产生对抗样本的原因是由于模型的线性特性是正确的。这种方法也可以作为一种快速生成对抗样本的方法(即FGSM)

线性模型的对抗训练

在Logistics Regression上应用FGSM方法 ,$label\in\lbrace1,-1\rbrace$

$P(y=1|x)=\sigma(w^Tx+b),\sigma(z)=softmax(z)$

$\therefore J = E{x,y \tilde{} p_{data}}[(-\frac{1+y}{2})\ln P(y=1|x)-\frac{1-y}{2}\ln P(y=-1|x)]$

设$p=P(y=1|x),f=w^Tx+b$

$\therefore J=-\frac{1}{2}\ln p-\frac{y}{2}\ln p-\frac{1}{2}\ln (1-p)+\frac{y}{2}\ln (1-p)$

$=-\frac{1}{2}\ln p(1-p)-\frac{y}{2}\ln \frac{p}{1-p} $

$= \frac{1}{2}(f-yf) + \ln(1+e^{-f})$

$=\begin{cases} \ln(1+e^{-f}),y=1\\ f+\ln(1+e^{-f})=\ln e^f+\ln(1+e^{-f})=\ln(1+e^f),y=-1\end{cases}$

$= \ln(1+e^{-yf})$

$=\zeta(-yf)=E{x,y \tilde{} p_{data}}\zeta(-y(w^Tx+b)),\zeta(z) = \ln(1+e^z)$

$\therefore \eta=\epsilon sign(\nabla_xJ(\theta,x,y))$

$=\epsilon sign(\nabla_x\zeta(-y(w^Tx+b)))$

$= \epsilon sign(\frac{\partial \ln(1+e^{-y(w^Tx+b)})}{\partial x})$

$=\epsilon sign(\frac{1}{1+e^{-y(w^Tx+b)}} ×(-e^{-y(w^Tx+b)})×(yw^T))$

$=\epsilon sign(\frac{e^{-yf}}{1+e^{-yf}}×(-y)w)$

$=\epsilon sign(-w)=-\epsilon sign(w)$

$\because w^Tsign(w)=||w||_1,\hat{x}=x+\eta,\eta=\epsilon-sign(w)$

$\therefore \hat{J}=E{x,y \tilde{} p_{data}}\zeta(y(\epsilon||w||_1 -w^Tx-b))$

可以看到类似于$L^1$正则,不过是减去$L^1$惩罚项。当置信度很高,$w^Tx+b$足够大的时候,$\epsilon||w||_1$几乎不起作用,但是当模型欠拟合的时候,则会更加欠拟合

深度网络的对抗训练

相比于纯线性模型,深度网络可以在训练网络过程中来抵御对抗攻击。

这种方法在训练中不断更新对抗样本,同时训练。

对抗样本的泛化原因

根据线性解释,FGSM可以在连续空间上生成对抗样本,而不是特定的点。作者通过取不同的$\epsilon$值证实了这一点。

为什么不同的分类器会将对抗样本误分到同一类?因为作者假设的模型都在训练集的不同子集上训练,模型泛化后学得的参数差不多,具有一定的稳定性,导致对抗样本也具有稳定性。


且听风吟