python神经网络工具箱_Foolbox:用于生成神经网络对抗样本的Python工具箱

68747470733a2f2f72656164746865646f63732e6f72672f70726f6a656374732f666f6f6c626f782f62616467652f3f76657273696f6e3d6c6174657374

68747470733a2f2f7472617669732d63692e6f72672f6265746867656c61622f666f6f6c626f782e7376673f6272616e63683d6d6173746572

68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6265746867656c61622f666f6f6c626f782f62616467652e737667

Foolbox

Foolbox is a Python toolbox to create adversarial examples that fool neural networks. It requires Python, NumPy and SciPy.

Installation

pip install foolbox

We test using Python 2.7, 3.5 and 3.6. Other Python versions might work as well. We recommend using Python 3!

Documentation

Documentation is available on readthedocs: http://foolbox.readthedocs.io/

Example

import foolbox

import keras

from keras.applications.resnet50 import ResNet50, preprocess_input

# instantiate model

keras.backend.set_learning_phase(0)

kmodel = ResNet50(weights='imagenet')

fmodel = foolbox.models.KerasModel(kmodel, bounds=(0, 255), preprocess_fn=preprocess_input)

# get source image and label

image, label = foolbox.utils.imagenet_example()

# apply attack on source image

attack = foolbox.attacks.FGSM(fmodel)

adversarial = attack(image, label)

Interfaces for a range of other deeplearning packages such as TensorFlow, PyTorch, Theano, Lasagne and MXNet are available, e.g.

model = foolbox.models.TensorFlowModel(images, logits, bounds=(0, 255))

model = foolbox.models.PyTorchModel(torchmodel, bounds=(0, 255), num_classes=1000)

# etc.

Different adversarial criteria such as Top-k, specific target classes or target probability values for the original class or the target class can be passed to the attack, e.g.

criterion = foolbox.criteria.TargetClass(22)

attack = foolbox.attacks.FGSM(fmodel, criterion)

Feature requests and bug reports

We welcome feature requests and bug reports. Just create a new issue on GitHub.

Questions

Depending on the nature of your question feel free to post it as an issue on GitHub, or post it as a question on Stack Overflow using the foolbox tag. We will try to monitor that tag but if you don't get an answer don't hesitate to contact us.

Contributions welcome

Foolbox is a work in progress and any input is welcome.

In particular, we encourage users of deep learning frameworks for which we do not yet have builtin support, e.g. Caffe, Caffe2 or CNTK, to contribute the necessary wrappers. Don't hestiate to contact us if we can be of any help.

Moreoever, attack developers are encouraged to share their reference implementation using Foolbox so that it will be available to everyone.

Citation

If you find Foolbox useful for your scientific work, please consider citing it in resulting publications. We will soon publish a technical paper and will provide the citation here.

Authors

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值