day01--对抗样本学习-论文复现

本文介绍如何使用Inceptionv3模型和TF-slim库生成对抗样本,并通过旋转增强其鲁棒性。对抗样本是一种经过微小扰动的输入,能够误导深度学习模型做出错误分类。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

攻击模型:Inception v3 数据集:ImageNet 原有预分类模型:TF-slim图像分类库
接论文
synthesizing-robust-adversarial-examples https://arxiv.org/abs/1707.07397
(综合强大的对抗样本)
代码:
http://www.anishathalye.com/media/2017/07/25/adversarial.ipynb(本文讲解)
https://github.com/prabhant/synthesizing-robust-adversarial-examples
参考:https://www.jiqizhixin.com/articles/2017-08-11-9
代码在jupyter notebook中可以直接打开,本文主要添加部分代码注释。
攻击模型:Inception v3 数据集:ImageNet 原有预分类模型:TF-slim图像分类库

import tensorflow as tf
import tensorflow.contrib.slim as slim
import tensorflow.contrib.slim.nets as nets
tf.logging.set_verbosity(tf.logging.ERROR)
sess = tf.InteractiveSession()
image = tf.Variable(tf.zeros((299, 299, 3)))

#设置输入图像:tf.Variable instead of a tf.placeholder 可训练
#tf.Variable:声明变量并赋值,tf.placeholder对声明的变量长期使用,节省内存

def inception(image, reuse):
    preprocessed = tf.multiply(tf.subtract(tf.expand_dims(image, 0), 0.5), 2.0)
    arg_scope = nets.inception.inception_v3_arg_scope(weight_decay=0.0)
    with slim.arg_scope(arg_scope):
        logits, _ = nets.inception.inception_v3(
            preprocessed, 1001, is_training=False, reuse=reuse)
        #299,299,3,1001是inceptionV3的标准参数
        logits = logits[:,1:] # ignore background class
        probs = tf.nn.softmax(logits) # probabilities
    return logits, probs

logits, probs = inception(image, reuse=False)

(一)正确分类

加载Inception v3模型后,用自己的一张照片来正确分类

在这里插入图片描述
然后生成对抗样本:

在这里插入图片描述

在这里插入图片描述
旋转后才有PGD保持对抗样本的攻击性:
在这里插入图片描述


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值