Certified Adversarial Robustness via Randomized Smoothing

Cohen J., Rosenfeld E., Kolter J. Certified Adversarial Robustness via Randomized Smoothing. International Conference on Machine Learning (ICML), 2019.

@article{cohen2019certified,
title={Certified Adversarial Robustness via Randomized Smoothing},
author={Cohen, Jeremy and Rosenfeld, Elan and Kolter, J Zico},
pages={1310--1320},
year={2019}}

Certified robustness 区别于一般的启发式的防御, 其在样本(x)满足一定的条件下(往往是一个类似于置信度的保证), 可以证明在某个范数球(往往是(ell_2), 正如本文)内能够免疫攻击, 即

[g(x+epsilon)=g(x):=arg max_{c in mathcal{Y}} : z(x), forall epsilon in mathcal{B}(x;R). ]

这些方法给出了一种不同于adversarial training的思路, 虽然到目前为止, 这些方法往往局限于(ell_1, ell_2)攻击, 在更为常见的(ell_{infty})的表现并不是特别好.

主要内容

方法很简单, 训练的时候:

  • Given inputs (x_i),
  • Generate gaussian noise (epsilon_i sim mathcal{N}(0, sigma^2));
  • Use (x_i+epsilon_i) to train.

实际上这个训练过程, 不从后面的理论的角度看, 可以把它和adversarial training做类比, 实际上都是一种在样本点周围试探性的训练过程. 大概这样子会让整个的loss landscape更加光滑?

测试的时候就不同了, 首先需要认为地设定一个采样次数(n),

  • Given input (x)
  • Generate (n) gaussian noise (epsilon_i, i=1, ldots, n).
  • For each (x+epsilon_i), the neural network will give a prediction label (c_i);
  • Count the prediction labels and find the most frequent one, denoted by (c).

(c)就是最终的预测是输出, 简而言之, 就是在预测的时候需要统计频率, 这个实际上是寻找最大概率点.

定理1

定理1: 假设(f:mathbb{R}^d ightarrow mathcal{Y}) 为一个任意的确定性或者随机的函数, (epsilon sim mathcal{N}(0, sigma^2I)). 定义(g)

[ ag{1} g(x):= arg max_{c in mathcal{Y}} mathbb{P}(f(x+epsilon)=c). ]

假设(c_A in mathcal{Y})(underline{p_A}, overline{p_B} in [0, 1])满足

[ ag{2} mathbb{P}(f(x+epsilon)=c_A) ge underline{p_A} ge overline{p_B} ge max_{c ot = c_{A}} mathbb{P}(f(x+epsilon)=c). ]

(g(x+delta)=c_A) 对于任意的(|delta|_2 < R), 其中

[ ag{3} R=frac{sigma}{2}(Phi^{-1}(underline{p_A})- Phi^{-1}(overline{p_B})). ]

定理1总结来说就是, 当你的(f(x+epsilon)=c_A)的概率比别的类别的概率大得多的时候, 由(1)式所得到的smooth版分类器(g)就能够在某个半径内免疫(ell_2)攻击.
但是需要注意的是, 普通的CNN的训练过程可以保证置信度很高但没法保证(2), 所以为了让(2)式成立这才有了上面的一个训练过程, 其中实际上有一个逼近的过程(虽然感觉有一点牵强):
在这里插入图片描述

测试过程中统计频率的行为也得到了解释, 实际上就是为了估计最大概率. 最后, 在作者的代码中, 或者说算法中, 测试的predict可能有点麻烦, 实际上这是作者引入了假设检验, 意图大概是为了有些时候没法判断到底哪个对干脆就不判断来保证安全(测试的时候感觉是没有必要的). 当然了, 在certify accuracy的估计中, (alpha)就是相当有必要了.

代码

原作者代码.

原文地址:https://www.cnblogs.com/MTandHJ/p/13714350.html