Page 361 - 《软件学报》2024年第6期
P. 361
周志阳 等: 谛听: 面向鲁棒分布外样本检测的半监督对抗训练方法 2937
into the in-distribution (ID) or OOD categories. Then, the detector itself can be re-bypassed by malicious adversarial attacks. These OOD
samples with malicious perturbations are called adversarial OOD samples. Building robust OOD detectors to detect adversarial OOD
samples is more challenging. Existing methods usually train DNN through adversarial OOD samples within the neighborhood of auxiliary
clean OOD samples to learn separable and robust representations to malicious perturbations. However, due to the distributional differences
between the auxiliary OOD training set and original ID training set, training adversarial OOD samples is not effective enough to ensure
the robustness of ID boundary against adversarial perturbations. Adversarial ID samples generated from within the neighborhood of (clean)
ID samples are closer to the ID boundary and are also effective in improving the adversarial robustness of the ID boundary. This study
proposes a semi-supervised adversarial training approach, DiTing, to build robust OOD detectors to detect clean and adversarial OOD
samples. This approach treats the adversarial ID samples as auxiliary “near OOD” samples and trains them jointly with other auxiliary
clean and adversarial OOD samples to improve the robustness of OOD detection. Experiments show that DiTing has a significant
advantage in detecting adversarial OOD samples generated by strong attacks while maintaining state-of-the-art performance in classifying
clean ID samples and detecting clean OOD samples.
Key words: out-of-distribution sample detection; adversarial robustness; adversarial training
深度神经网络 (deep neural network, DNN) 在图像识别 [1] 、自动驾驶 [2] 和医学诊断 [3] 等各个领域都取得了前所
未有的性能, 广泛地应用于各种对安全敏感的领域. 然而, DNN 分类器容易对来自训练集分布之外的分布外 (out-
of-distribution, OOD) 样本过信心 [4] , 以较高的预测信心而产生误分类. 例如, 将一张“键盘”的图片输入给一个在
“猫”和“狗”数据集上训练的 DNN 分类器, 其可能以 90% 以上的 Softmax 信心将该图片分类为“猫”. 检测 OOD 样
本对 DNN 在开放环境的部署至关重要.
检测 OOD 样本是一种二分类问题, 即把输入样本分类为“分布内”类或“分布外”类. 当前多数检测方法可以划
分为两种方法路线. 第 1 种路线侧重于为已有 (pre-trained) DNN 模型设计基于阈值的检测/打分函数 (scoring
function) 来检测 OOD 样本 [5−8] . 当输入样本的分数小 (大) 于某阈值时, 则将其判断为 OOD 样本. 在这些打分函数
中, 较高效或有效的且与我们的工作相关的是基于统计的打分函数, 如基于 DNN 的最大 Softmax 概率 (maximum
Softmax probability, MSP) [5,6,9] 的打分函数. 基于统计的打分函数将 DNN 视为一个特征提取器, 并使用其隐藏层或/
和输出层所蕴含的信息作为输入来区分 ID 样本和 OOD 样本.
第 2 种方法侧重于重新训练 检测器而注入了恶意扰动的
样本和
DNN, 以习得对
发现使用围绕在
[9]
样本可分离的表示. Lee 等人
OOD
ID
分布内区域附近的 OOD 样本对压缩分布内区域更有效; 他们同时训练分类器和 GAN, 使分类器在 GAN [10] 生成的
“边界”数据上输出均匀分布来帮助校验该分类器的预测信心 (即使 DNN 对测试样本的平均预测信心接近于其准
[6]
确率). 半监督的 OE 进一步地使用多样的、真实世界的辅助 OOD 数据集来帮助校验 DNN 的预测信心; OE 训
练 DNN 对辅助的 OOD 样本输出一个均匀分布, 并首次大幅度地提升了检测 OOD 样本的性能. 紧随 OE 之后, 半
监督的 SSL [11] 使用多个额外的“拒绝”类来表示 OOD 样本, 并相较于 OE 取得了进一步的性能提升. 总结来看, 检
测 OOD 样本问题得到了较好的解决 [12,13] .
然而, 与 DNN 分类器的弱鲁棒性类似, 最近的工作 [14−16] 表明多数先进的 OOD 检测方法同样对恶意的对抗扰
动 [17−19] 敏感,易被注入了对抗扰动的 OOD 样本再次绕过. 例如, 攻击者可通过注入一些对抗扰动到分布外的广告
牌上, 以骗过自动驾驶系统将并其识别为“右转”标识. 为了后续便于描述, 本文把无恶意目的 OOD 样本称为干净
OOD 样本, 把为了绕过 OOD OOD 样本称为对抗 OOD 样本. 检测对抗 OOD 样本是
一项更具挑战性的任务. 受对抗训练 (adversarial training, AT) [20,21] 的启发, 已有工作大多在辅助的 OOD 样本上直
接引入 AT 来帮助提升 OOD 检测器的鲁棒性. 在常规鲁棒性研究领域, AT 为对抗样本分配与其干净样本一样的
标签, 将对抗样本视为一种数据增强来训练 DNN 分类器. 尽管 AT 有效地保证了 DNN 的鲁棒性, 但其强制 DNN
完全忽略与标签弱相关的扰动特征来辅助决策, 导致 DNN 在原 ID 样本上的分类准确率显著下降 [22] . Hein 等人 [15]
分析了为什么使用 ReLU 激活函数的 DNN 易对 OOD 样本产生高置信度, 并提出了 ACET 在辅助的 OOD 样本上
引入 AT 来帮助缓解此问题; ACET 训练 DNN 对干净 OOD 样本和对抗 OOD 样本一个均匀分布的预测概率.
ATOM [16] 进一步提出一种辅助 OOD 样本挖掘策略, 并使用第 K+1“拒绝”类来专有地表示干净 OOD 样本和对抗
OOD 样本. 此外, ALOE [12] 和 RATIO [13] 在 ID 样本和辅助的 OOD 样本上同时引入常规的 AT 而不使用任何干净