運用對抗例攻擊深度學習模型(一)

Pomin Wu
TrustableAI
Published in
9 min readAug 29, 2017
Sherden guards with double-edge swords as published by Ippolito Rosellini, Public domain

本文同步刊登於 Trustable AI 部落格

這是一系列針對對抗例(adversarial example)相關研究的綜合摘要的第一篇。本系列包括:

利用對抗例(adversarial example)造成深度學習模型判斷錯誤這種攻擊手法,到 2017 年中為止看來是攻擊方略佔上風,目前看來針對 Papernot et al(2016) [1]等人發表的 transfer attack 的防禦進展不大,而產生對抗例的方法仍然在持續簡化中。

Papernot et al(2016) 發表的攻擊方式是目前最具威力的一種,針對影像辨識的深度學習服務,可以透過 API 取得一些分類結果後,另外在本地訓練一個 local model,對 local model 找出可用的對抗例,轉移(transfer)回去攻擊目標 API。論文裡對 Amazon 與 Google 的服務實測都有近 90% 的成功率。簡單地說,黑箱攻擊是可行的。

所謂對抗例,是一種刻意製造的、讓機器學習模型判斷錯誤的輸入資料。最早是 Szegedy et al(2013)[2]發現對於用 ImageNet、AlexNet 等資料集訓練出來的影像辨識模型,常常只需要輸入端的微小的變動,就可以讓輸出結果有大幅度的改變。例如取一張卡車的照片,可以被模型正確辨識,但只要改變影像中的少數像素,就可以讓模型辨識錯誤,而且前後對影像的改變非常少,對肉眼而言根本分不出差異。

這樣的例子除了顯現深度學習模型可能結果「不穩定」,而且有可能被惡意利用而有安全疑慮,因此近年來已經成為機器學習熱門的研究議題。2017 年這方面發表的研究成果,主要有加強防禦,以及更快速簡單地產生對抗例兩個方向。但是目前看來針對上述 Papernot 等人發表的 transfer attack 的防禦進展不大,而產生對抗例的方法仍然在持續簡化中。

以下將回顧對抗例的重要特性、製造對抗例的演算法,以及一些防禦的策略。下一回我們會整理一些 2017 年目前為止的進展。此外,Open AI 的 Attacking Machine Learning with Adversarial Examples 一文也是相當完整的入門參考資料。

對抗例的特性與可能原因

Szegedy et al(2013)有幾個基本的發現:

  1. 取同一套資料集裡的不同部份做為訓練資料,而且採用不同的網路架構,按理說訓練出來的 DNN 不一樣。但實驗發現這些 DNN 往往會被同一個對抗例所欺騙。換句話說,一個 DNN 上找到的對抗例經常可以轉移(transfer)到針對同一個問題的另一個 DNN 上。
  2. 找對抗例基本上是個最佳化問題,要在一個輸入的資料點位附近用演算法去找。隨機 perturb 的成功率不大。

目前為止,對對抗例的存在的解釋,傾向認為這來自 model 中的線性計算部份。在 Goodfellow et al(2014)[3]是這樣解釋的:線性的計算基本上就是像 z=wx+b 這樣的步驟,其中 wb 是 weight 與 bias,x 是 input,z 是 stimulation,wx 都是向量,wx 是向量內積。因此當 dw 平行時,z’=w(x+d)+b=wx+wd+b 可以因為一個微小的變動 d 產生很大的輸出結果改變(wd 很大)。當這些向量的維度很高(即 model feature 很多)的時候,wd 就可以大到造成誤判。

這個看法可以得出幾個結果:

  • 這解釋了過去用的 regularization 手法例如 dropout、pretraining、model average 防堵攻擊的效果不大。
  • 這表示對抗例的存在來自於 decision boundary 的幾何性質,所以這也解釋了 transferability。
  • 如果換成非線性 model 例如 RBF network,就可以降低攻擊的效果。當然非線性 model 的訓練比較難,因此 model programmer 面臨的問題就是要在好訓練、容易被攻擊的線性 model,與難訓練、不容易被攻擊的非線性 model 之間做平衡。

製造對抗例的演算法

目前為止找對抗例的演算法,比較好的有兩個:

而這類攻擊的威脅模型,可以依以下性質區別成幾類(Papernot et al(2016))。

Adversarial goals 攻擊目的(由容易到困難)

  1. Confidence reduction:降低信心
  2. Misclassification:讓 output 跑掉
  3. Targeted misclassification:製造一個 input 讓 output 是特定值
  4. Source/target misclassify:把一個特定 input 修改到讓 output 是特定值

Adversarial capabilities 攻擊方需要知道的資訊(由多到少)

  1. Architecture & training data
  2. Architecture
  3. Training data sample
  4. Oracle
  5. Samples

從這個威脅模型來分析,前面列舉的研究,攻擊目的都是 (4)。攻擊方需要知道的資訊,在 2015 年以前都是 (2)(需要知道 network architecture),在 2016 年已經做到 (4)(可以 probe API 取得預測結果即可)。

值得注意是,透過 Tramer et al(2016)[5]這樣的手法,攻擊方也可能透過 API 取得關於 network architecture 的資訊,再運用到對抗例的攻擊上。

防禦的策略

防禦的策略則分成被動(reactive)與主動(proactive)兩大類:

  • 被動防禦:受到攻擊以後再防禦,以「試圖在 input 中過濾出對抗例」為主。
  • 主動防禦:事先預防,以「試圖調整訓練過程,讓訓練出來的 model 不容易被算出對抗例」為主。

主動防禦又有兩大類:

  • Adversarial training(Shaham et al(2015)[6]):產生對抗例用來訓練 model,減少 perturbation 造成的改變。這樣訓練過後的 model 局部較穩定,不容易再找出對抗例。
  • Defensive distillation(Papernot et al(2016)[7]):把 model 預測的 probability vector 餵回去給 model 稀釋一下 weight,讓新的 decision boundary 平滑一點,就不容易找到對抗例了。

原先看起來最有效的是 defense distillation,可以抵擋 FGSM 與 JSMA 兩種主要的演算法。但是在 Papernot et al(2016)Carlini et al(2016)[8]提出新的攻擊手法以後,這個防禦就沒那麼有效了。Papernot et al(2017)[9]試圖補強 defensive distillation 但效果有限。

2017/08/30 更新

感謝 David Tung 指出,adversarial 詞意為「對抗的、敵對的」,只表示涉及討論的兩方立場不同,並不具有「含有惡意」的意思。本文原先將 adversarial example 翻譯為「惡意資料」並不貼切,經建議改為較準確而且中性的「對抗例」一詞。

參考文獻

  1. N. Papernot, P. McDaniel, S. Jha, M. Fredrikson, Z. B. Celik, and A. Swami, “The Limitations of Deep Learning in Adversarial Settings,” in 2016 IEEE European Symposium on Security and Privacy, 2016, pp. 372–387.
  2. C. Szegedy et al., “Intriguing properties of neural networks,” arXiv:1312.6199 [cs], Dec. 2013.
  3. I. J. Goodfellow, J. Shlens, and C. Szegedy, “Explaining and harnessing adversarial examples,” arXiv preprint arXiv:1412.6572, 2014.
  4. N. Papernot, P. McDaniel, S. Jha, M. Fredrikson, Z. B. Celik, and A. Swami, “The Limitations of Deep Learning in Adversarial Settings,” in 2016 IEEE European Symposium on Security and Privacy, 2016, pp. 372–387.
  5. Florian Tramèr, Fan Zhang, and Ari Juels, “Stealing Machine Learning Models via Prediction APIs,” in Proceedings of the 25th USENIX Security Symposium, Berkeley, CA, 2016, vol. 25th USENIX Security Symposium, pp. 601–618.
  6. U. Shaham, Y. Yamada, and S. Negahban, “Understanding Adversarial Training: Increasing Local Stability of Neural Nets through Robust Optimization,” arXiv preprint arXiv:1511.05432, 2015.
  7. N. Papernot, P. McDaniel, X. Wu, S. Jha, and A. Swami, “Distillation as a Defense to Adversarial Perturbations Against Deep Neural Networks,” in 2016 IEEE Symposium on Security and Privacy (SP), 2016, pp. 582–597.
  8. N. Carlini and D. Wagner, “Towards Evaluating the Robustness of Neural Networks,” arXiv:1608.04644 [cs], Aug. 2016.
  9. N. Papernot and P. McDaniel, “Extending Defensive Distillation,” arXiv preprint arXiv:1705.05264, May 2017.

對抗例入門說明 — 運用對抗例攻擊深度學習模型(一)

--

--

Pomin Wu
TrustableAI

Co-founder of Trustable AI. Interested in mathematics, photography, map, open culture.