Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
982be7ce
M
models
项目概览
PaddlePaddle
/
models
大约 1 年 前同步成功
通知
222
Star
6828
Fork
2962
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
602
列表
看板
标记
里程碑
合并请求
255
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
models
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
602
Issue
602
列表
看板
标记
里程碑
合并请求
255
合并请求
255
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
982be7ce
编写于
1月 25, 2018
作者:
wgzqz
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix some PEP8 warning.
上级
9542bab2
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
24 addition
and
12 deletion
+24
-12
fluid/adversarial/advbox/__init__.py
fluid/adversarial/advbox/__init__.py
+3
-3
fluid/adversarial/advbox/attacks/base.py
fluid/adversarial/advbox/attacks/base.py
+6
-5
fluid/adversarial/advbox/attacks/gradientsign.py
fluid/adversarial/advbox/attacks/gradientsign.py
+8
-0
fluid/adversarial/advbox/attacks/iterator_gradientsign.py
fluid/adversarial/advbox/attacks/iterator_gradientsign.py
+2
-2
fluid/adversarial/advbox/models/__init__.py
fluid/adversarial/advbox/models/__init__.py
+2
-2
fluid/adversarial/advbox/models/paddle.py
fluid/adversarial/advbox/models/paddle.py
+3
-0
未找到文件。
fluid/adversarial/advbox/__init__.py
浏览文件 @
982be7ce
...
...
@@ -2,6 +2,6 @@
A set of tools for generating adversarial example on paddle platform
"""
from
.
import
attacks
# type: ignore # noqa: F401
from
.
import
models
# type: ignore # noqa: F401
from
.adversary
import
Adversary
# noqa: F401
from
.
import
attacks
from
.
import
models
from
.adversary
import
Adversary
fluid/adversarial/advbox/attacks/base.py
浏览文件 @
982be7ce
...
...
@@ -29,18 +29,19 @@ class Attack(object):
Args:
adversary(object): The adversary object.
**kwargs: Other
param
s.
**kwargs: Other
named argument
s.
"""
self
.
_preprocess
(
adversary
)
return
self
.
_apply
(
adversary
,
**
kwargs
)
@
abstractmethod
def
_apply
(
self
,
adversary
):
def
_apply
(
self
,
adversary
,
**
kwargs
):
"""
Search an adversarial example.
Args:
adversary(object): The adversary object.
**kwargs: Other named arguments.
"""
raise
NotImplementedError
...
...
@@ -65,6 +66,6 @@ class Attack(object):
logging
.
info
(
'adversary:
\n
original_label: {}'
'
\n
target_lable: {}'
'
\n
is_targeted_attack: {}'
.
format
(
adversary
.
original_label
,
adversary
.
target_label
,
adversary
.
is_targeted_attack
))
'
\n
is_targeted_attack: {}'
''
.
format
(
adversary
.
original_label
,
adversary
.
target_label
,
adversary
.
is_targeted_attack
))
fluid/adversarial/advbox/attacks/gradientsign.py
浏览文件 @
982be7ce
...
...
@@ -20,6 +20,14 @@ class GradientSignAttack(Attack):
"""
def
_apply
(
self
,
adversary
,
epsilons
=
1000
):
"""
Apply the gradient sign attack.
Args:
adversary(Adversary): The Adversary object.
epsilons(list|tuple|int): The epsilon (input variation parameter).
Return:
adversary: The Adversary object.
"""
assert
adversary
is
not
None
if
not
isinstance
(
epsilons
,
Iterable
):
...
...
fluid/adversarial/advbox/attacks/iterator_gradientsign.py
浏览文件 @
982be7ce
...
...
@@ -21,11 +21,11 @@ class IteratorGradientSignAttack(Attack):
"""
Apply the iterative gradient sign attack.
Args:
adversary(
object): The image and label tuple list of one elemen
t.
adversary(
Adversary): The Adversary objec
t.
epsilons(list|tuple|int): The epsilon (input variation parameter).
steps(int): The number of iterator steps.
Return:
numpy.ndarray: The adversarail sample generated by the algorithm
.
adversary(Adversary): The Adversary object
.
"""
if
not
isinstance
(
epsilons
,
Iterable
):
...
...
fluid/adversarial/advbox/models/__init__.py
浏览文件 @
982be7ce
"""
Paddle model for target of attack
"""
from
.base
import
Model
# noqa: F401
from
.paddle
import
PaddleModel
# noqa: F401
from
.base
import
Model
from
.paddle
import
PaddleModel
fluid/adversarial/advbox/models/paddle.py
浏览文件 @
982be7ce
"""
Paddle model
"""
from
__future__
import
absolute_import
import
paddle.v2.fluid
as
fluid
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录