Universal adversarial perturbations
@article{moosavidezfooli2017universal,
title={Universal Adversarial Perturbations},
author={Moosavidezfooli, Seyedmohsen and Fawzi, Alhussein and Fawzi, Omar and Frossard, Pascal},
pages={86--94},
year={2017}}
概
深度学习的脆弱以及周知了, 但是到底脆弱到何种程度, 本文作者发现, 可以找到一种对抗摄动, 令其作用在不同的数据上, 结果大部分都会被攻破(即被网络误判). 甚至, 这种对抗摄动可以跨越网络结构的障碍, 即在这个网络结构上的一般性的对抗摄动, 也能有效地攻击别的网络.
主要内容
一般地对抗样本, 是针对特定的网络\(\hat{k}\), 特定的样本\(x_i \in \mathbb{R}^d\), 期望找到摄动\(v_i \in \mathbb{R}^d\), 使得
\]
而本文的通用摄动(universal perturbations)是希望找到一个\(v, \|v\|_p \le \xi\), 且
\]
其中\(\mu\)为数据的分布.
算法
构造这样的\(v\)的算法如下:
其中
\]
为向\(p\)范数球的投影.
实验部分
实验1
实验1, 在训练数据集(ILSVRC 2012)\(X\)上(摄动是在此数据上计算得到的), 以及在验证数据集上, 攻击不同的网络.
实验2
实验2测试这种通用摄动的网络结构的转移性, 即在一个网络上寻找摄动, 在其它模型上计算此摄动的攻击成功率. 可见, 这种通用摄动的可迁移性是很强的.
实验3
实验3, 研究了样本个数对攻击成功率的一个影响, 可以发现, 即便我们用来生成摄动的样本个数只有500(少于类别个数1000)都能有不错的成功率.
代码
代码因为还有用到了别的模块, 这放在这里看看, 论文有自己的代码.
import torch
import logging
from configs.adversarial.universal_attack_cfg import cfg
sub_logger = logging.getLogger("__main__.__submodule__")
class AttackUni:
def __init__(self, net, device,
attack=cfg.attack, epsilon=cfg.epsilon, attack_cfg=cfg.attack_cfg,
max_iterations=cfg.max_iterations, fooling_rate=cfg.fooling_rate,
boxmin=0., boxmax=1.):
""" the attack to construct universal perturbation
:param net: the model
:param device: may use gpu to train
:param attack: default: PGDAttack
:param epsilon: the epsilon to constraint the perturbation
:param attack_cfg: the attack's config
:param max_iterations: max_iterations for stopping early
:param fooling_rate: the fooling rate we want
:param boxmin: default: 0
:param boxmax: default: 1
"""
attack_cfg['net'] = net
attack_cfg['device'] = device
self.net = net
self.device = device
self.epsilon = epsilon
self.attack = attack(**attack_cfg)
self.max_iterations = max_iterations
self.fooling_rate = fooling_rate
self.boxmin = boxmin
self.boxmax = boxmax
def initialize_perturbation(self):
self.perturbation = torch.tensor(0., device=self.device)
def update_perturbation(self, perturbation):
self.perturbation += perturbation
self.perturbation = self.clip(self.perturbation).to(self.device)
def clip(self, x):
return torch.clamp(x, -self.epsilon, self.epsilon)
def compare(self, x, label):
x_adv = x + self.perturbation
out = self.net(x_adv)
pre = out.argmax(dim=1)
return (pre == label).sum()
def attack_one(self, img):
result = self.attack.attack_batch(img+self.perturbation)
perturbation = result['perturbations'][0]
self.update_perturbation(perturbation)
def attack_batch(self, dataloader):
total = len(dataloader)
self.initialize_perturbation()
for epoch in range(self.max_iterations):
count = 0
for img, label in dataloader:
img = img.to(self.device)
label = img.to(self.device)
if self.compare(img, label):
self.attack_one(img)
else:
count += 1
if count / total > self.fooling_rate:
break
sub_logger.info("[epoch: {0:<3d}] 'fooling_rate': {1:<.6f}".format(
epoch, count / total
))
return self.perturbation
Universal adversarial perturbations的更多相关文章
- Distillation as a Defense to Adversarial Perturbations against Deep Neural Networks
目录 概 主要内容 算法 一些有趣的指标 鲁棒性定义 合格的抗干扰机制 Nicolas Papernot, Patrick McDaniel, Xi Wu, Somesh Jha, Ananthram ...
- 论文阅读 | Universal Adversarial Triggers for Attacking and Analyzing NLP
[code] [blog] 主要思想和贡献 以前,NLP中的对抗攻击一般都是针对特定输入的,那么他们对任意的输入是否有效呢? 本文搜索通用的对抗性触发器:与输入无关的令牌序列,当连接到来自数据集的任何 ...
- (转) AdversarialNetsPapers
本文转自:https://github.com/zhangqianhui/AdversarialNetsPapers AdversarialNetsPapers The classical Pap ...
- ICCV 2017论文分析(文本分析)标题词频分析 这算不算大数据 第一步:数据清洗(删除作者和无用的页码)
IEEE International Conference on Computer Vision, ICCV 2017, Venice, Italy, October 22-29, 2017. IEE ...
- CVPR 2017 Paper list
CVPR2017 paper list Machine Learning 1 Spotlight 1-1A Exclusivity-Consistency Regularized Multi-View ...
- (转)Awesome Knowledge Distillation
Awesome Knowledge Distillation 2018-07-19 10:38:40 Reference:https://github.com/dkozlov/awesome-kno ...
- (转)Is attacking machine learning easier than defending it?
转自:http://www.cleverhans.io/security/privacy/ml/2017/02/15/why-attacking-machine-learning-is-easier- ...
- [转]GAN论文集
really-awesome-gan A list of papers and other resources on General Adversarial (Neural) Networks. Th ...
- zz姚班天才少年鬲融凭非凸优化研究成果获得斯隆研究奖
姚班天才少年鬲融凭非凸优化研究成果获得斯隆研究奖 近日,美国艾尔弗·斯隆基金会(The Alfred P. Sloan Foundation)公布了2019年斯隆研究奖(Sloan Research ...
随机推荐
- Hadoop入门 集群时间同步
集群时间同步 如果服务器在公网环境(能连接外网),可以不采用集群时间同步.因为服务器会定期和公网时间进行校准. 如果服务器在内网环境,必须要配置集群时间同步,否则时间久了,会产生时间偏差,导致集群执行 ...
- The Go tools for Windows + Assembler很好玩
我想用python做个tiny BASIC编译器.赋值和加减乘除,IF和FOR. 语法分析python有ply包,用ply.lex和ply.yacc做个计算器很简单,我已经做了. 做个解释器应该也不难 ...
- 大数据学习----day27----hive02------1. 分桶表以及分桶抽样查询 2. 导出数据 3.Hive数据类型 4 逐行运算查询基本语法(group by用法,原理补充) 5.case when(练习题,多表关联)6 排序
1. 分桶表以及分桶抽样查询 1.1 分桶表 对Hive(Inceptor)表分桶可以将表中记录按分桶键(某个字段对应的的值)的哈希值分散进多个文件中,这些小文件称为桶. 如要按照name属性分为3个 ...
- 注册页面的servlet
package cn.itcast.travel.web.servlet;import cn.itcast.travel.domain.ResultInfo;import cn.itcast.trav ...
- 【力扣】122. 买卖股票的最佳时机 II
给定一个数组,它的第 i 个元素是一支给定股票第 i 天的价格. 设计一个算法来计算你所能获取的最大利润.你可以尽可能地完成更多的交易(多次买卖一支股票). 注意:你不能同时参与多笔交易(你必须在再次 ...
- 【C#】【假条生成系统】【单位剖析】如何判断在文本框输入了几个人名?
我们规定,人名和人名之间使用顿号隔开 那么, 1个人,就是0个顿号 2个人,就是1个顿号 3个人,就是2个顿号 -- 所以我们可以判断文本框中顿号的出现次数. 出现0次,则为1人,出1次,则为两人. ...
- Python基础入门(5)- 函数的定义与使用
定义函数 函数的定义 函数的分类 函数的创建方法 函数的返回return 函数的定义 将一件事情的步骤封装在一起并得到最终结果 函数名代表了这个函数要做的事情 函数体是实现函数功能的流程 函数可以帮助 ...
- MySQL获取对应时间
一.查询当前时间包含年月日 SELECT CURDATE(); SELECT CURRENT_DATE(); 二.查询当前时间包含年月日时分秒 SELECT NOW(); SELECT SYSDATE ...
- BJD4th pwn pi
没记错的话,比赛那天正好是圣诞节,就只看了这一道pwn题,我还没做出来.我太菜了. 有一说一,ida换成7.5版本之后,一些去掉符号表的函数也能被识别出来了,ida更好用了呢. 题目程序分为两块,先看 ...
- 19.CSS3
前端三要素: HTML (结构)+ CSS(表现)+ JavaScript (行为) 一.什么是 CSS 1. CSS 是什么 CSS :Cascading Style Sheets ,层叠(级联)样 ...