← 开源
Hyperparticle

one-pixel-attack-keras

Keras implementation of "One pixel attack for fooling deep neural networks" using differential evolution on Cifar10 and ImageNet

TutorialsML/AI fundamentalsJupyter Notebook
在 GitHub 打开
增长势头
+024 小时新增 Star0.0%
1.24k
Star
214
Fork
+1
本周
3
贡献者
创建于 2018-02-17 · 更新于 2026-10-13 · 今日第 11008 名
主要开发者
Hyperparticlefalcaopetrijaewoosong

Hyperparticle/one-pixel-attack-keras 排名第 11,008,有 1,240 个星标。

同类别比较

Hyperparticle/one-pixel-attack-keras 排名第 11,008,此处有 8 个同类条目;mlbvn/ml-yearning-vi 排名第 11,012。

同类别比较
名称排名指标
dreddnafious/thereisnospoon10,980
语言:
Python
星标数:
1,246
分叉数:
95
简介:
A machine learning primer built from first principles. For engineers who want to reason about ML systems the way they reason about software systems.
doggy8088/github-copilot-configs10,994
星标数:
1,243
分叉数:
186
简介:
Will 保哥整理的最佳 GitHub Copilot 設定
samwit/llm-tutorials11,000
语言:
Jupyter Notebook
星标数:
1,242
分叉数:
312
简介:
A set of LLM Tutorials from my youtube channel
wangyuGithub01/Machine_Learning_Resources11,001
星标数:
1,242
分叉数:
179
简介:
:fish::fish::fish: 机器学习面试复习资源
mlbvn/ml-yearning-vi11,012
语言:
Python
星标数:
1,239
分叉数:
396
简介:
Một cuốn sách tập trung vào hướng dẫn cách cấu trúc các dự án Học Máy và phân tích cách làm cho các thuật toán Học Máy hoạt động.
dsgiitr/graph_nets11,025
语言:
Jupyter Notebook
星标数:
1,236
分叉数:
226
简介:
PyTorch Implementation and Explanation of Graph Representation Learning papers: DeepWalk, GCN, GraphSAGE, ChebNet & GAT.
campusx-official/ML-Roadmap-for-202211,030
星标数:
1,235
分叉数:
579
简介:
A curated list of Machine learning videos, links, projects and datasets to help you conquer the ML landscape in 6 months
MorvanZhou/Evolutionary-Algorithm11,035
语言:
Python
星标数:
1,234
分叉数:
618
简介:
Evolutionary Algorithm using Python, 莫烦Python 中文AI教学
关键参数与规格
关键参数与规格
参数值
语言Jupyter Notebook
类别Tutorials
子类别ML/AI fundamentals
星标数1,240
分叉数214
贡献者3
创建日期2018-02-17
更新日期2026-10-13
1 天星标数0
7 天星标数1
排名11,008
上次排名10,970
排名变化-38
7 天星标排名10,035
上次 7 天星标排名10,075
7 天星标排名变化40
总星标排名9,443
上次总星标排名9,434
总星标排名变化-9
国家USA
README 摘录

One Pixel Attack How simple is it to cause a deep neural network to misclassify an image if an attacker is only allowed to modify the color of one pixel and only see the prediction probability? In many cases, an attacker can even cause the network to return any answer they want. The following project is a Keras reimplementation and tutorial of "One pixel attack for fooling deep neural networks". The official code for the paper can be found here

. How It Works For this attack, we will use the Cifar10 dataset. The task of the dataset is to correctly classify a 32x32 pixel image in 1 of 10 categories (e. The black-box attack requires only the probability labels (the probability value for each category) that get outputted by the neural network. We generate adversarial images by selecting a pixel and modifying it to a certain color. By using an Evolutionary Algorithm called Differential Evolution (DE), we can iteratively

generate adversarial images to try to minimize the confidence (probability) of the neural network's classification. Mier's Blog First, generate several adversarial samples that modify a random pixel and run the images through the neural network. Next, combine the previous pixels' positions and colors together, generate several more adversarial samples from them, and run the new images through the neural network. If there were pixels that lowered the confidence of the network from the last step, replace them as the current

best known solutions. Repeat these steps for a few iterations; then on the last step return the adversarial image that reduced the network's confidence the most. If successful, the confidence would be reduced so much that a new (incorrect) category now has the highest classification confidence. See below for some examples of successful attacks: Getting Started Need a GPU or just want to read? View the first tutorial notebook with Google Colab. To run the code in the tutorial locally

, a dedicated GPU suitable for running with Keras ( ) is recommended. Install the python packages in requirements. Run the iPython tutorial notebook with Jupyter. Training and Testing To train a model, run . The model will be checkpointed (saved) after each epoch to the directory. For example, to train a ResNet with 200 epochs and a batch size of 128: To perform attack, run . By default this will run all models with default parameters. To specify the types of models to test

, use . The available models currently are: - LeNet, first CNN model - A NN with just convolutional layers - Network in Network - Deep Residual Learning for Image Recognition - Densely Connected Convolutional Networks - Wide Residual Networks - Dynamic Routing Between Capsules Results Preliminary results after running several experiments on various models. Each experiment generates 100 adversarial images and calculates the attack success rate, i. , the ratio of images that successfully caused the model to misclassify an image over the total number of images. For a

given model, multiple experiments are run based on the number of pixels that may be modified in an image (1

常见问题

记录了多少星标和分叉?

Hyperparticle/one-pixel-attack-keras 有 1,240 个星标和 214 个分叉。

仓库排名是多少?

Hyperparticle/one-pixel-attack-keras 排名第 11,008。

记录的语言和类别是什么?

Hyperparticle/one-pixel-attack-keras 有 1,240 个星标,语言为 Jupyter Notebook,类别为 Tutorials。

哪个仓库排名最接近?

Hyperparticle/one-pixel-attack-keras 与 mlbvn/ml-yearning-vi 比较,后者排名第 11,012,有 1,239 个星标。

README

One Pixel Attack

How simple is it to cause a deep neural network to misclassify an image if an attacker is only allowed to modify the color of one pixel and only see the prediction probability? Turns out it is very simple. In many cases, an attacker can even cause the network to return any answer they want.

The following project is a Keras reimplementation and tutorial of "One pixel attack for fooling deep neural networks". The official code for the paper can be found here.

How It Works

For this attack, we will use the Cifar10 dataset. The task of the dataset is to correctly classify a 32x32 pixel image in 1 of 10 categories (e.g., bird, deer, truck). The black-box attack requires only the probability labels (the probability value for each category) that get outputted by the neural network. We generate adversarial images by selecting a pixel and modifying it to a certain color.

By using an Evolutionary Algorithm called Differential Evolution (DE), we can iteratively generate adversarial images to try to minimize the confidence (probability) of the neural network's classification.

Credit: Pablo R. Mier's Blog

First, generate several adversarial samples that modify a random pixel and run the images through the neural network. Next, combine the previous pixels' positions and colors together, generate several more adversarial samples from them, and run the new images through the neural network. If there were pixels that lowered the confidence of the network from the last step, replace them as the current best known solutions. Repeat these steps for a few iterations; then on the last step return the adversarial image that reduced the network's confidence the most. If successful, the confidence would be reduced so much that a new (incorrect) category now has the highest classification confidence.

See below for some examples of successful attacks:

Getting Started

Need a GPU or just want to read? View the first tutorial notebook with Google Colab.

To run the code in the tutorial locally, a dedicated GPU suitable for running with Keras (tensorflow-gpu) is recommended. Python 3.5+ required.

  1. Clone the repository.
git clone https://github.com/Hyperparticle/one-pixel-attack-keras
cd ./one-pixel-attack-keras
  1. Install the python packages in requirements.txt if you don't have them already.
pip install -r ./requirements.txt
  1. Run the iPython tutorial notebook with Jupyter.
jupyter notebook ./one-pixel-attack.ipynb

Training and Testing

To train a model, run train.py. The model will be checkpointed (saved) after each epoch to the networks/models directory.

For example, to train a ResNet with 200 epochs and a batch size of 128:

python train.py --model resnet --epochs 200 --batch_size 128

To perform attack, run attack.py. By default this will run all models with default parameters. To specify the types of models to test, use --model.

python attack.py --model densenet capsnet

The available models currently are:

Results

Preliminary results after running several experiments on various models. Each experiment generates 100 adversarial images and calculates the attack success rate, i.e., the ratio of images that successfully caused the model to misclassify an image over the total number of images. For a given model, multiple experiments are run based on the number of pixels that may be modified in an image (1,3, or 5). The differential algorithm was run with a population size of 400 and a max iteration count of 75.

Attack on 1,3,5 pixel perturbations (100 samples)

model parameters test accuracy pixels attack success (untargeted) attack success (targeted)
LeNet 62K 74.9% 1 63.0% 34.4%
3 92.0% 64.4%
5 93.0% 64.4%
Pure CNN 1.4M 88.8% 1 13.0% 6.67%
3 58.0% 13.3%
5 63.0% 18.9%
Network in Network 970K 90.8% 1 34.0% 10.0%
3 73.0% 24.4%
5 73.0% 31.1%
ResNet 470K 92.3% 1 34.0% 14.4%
3 79.0% 21.1%
5 79.0% 22.2%
DenseNet 850K 94.7% 1 31.0% 4.44%
3 71.0% 23.3%
5 69.0% 28.9%
Wide ResNet 11M 95.3% 1 19.0% 1.11%
3 58.0% 18.9%
5 65.0% 22.2%
CapsNet 12M 79.8% 1 19.0% 0.00%
3 39.0% 4.44%
5 36.0% 4.44%

It appears that the capsule network CapsNet, while more resilient to the one pixel attack than all other CNNs, is still vulnerable.

Milestones

  • [x] Cifar10 dataset
  • [x] Tutorial notebook
  • [x] LeNet, Network in Network, Residual Network, DenseNet models
  • [x] CapsNet (capsule network) model
  • [x] Configurable command-line interface
  • [x] Efficient differential evolution implementation
  • [x] ImageNet dataset
排名相邻
同类项目