Overview
The implementation is structured by the attack method. Each is implemented in a separate notebook. The first notebook 00_Helper-Functions.ipynb
contains functions that are required by multiple methods. Copies of these functions are available as modules in modules/helper.py
and modules/dataset.py
. The PyTorch library is used for the implementations.
The available notebooks are:
00_Helper-Functions.ipynb
01_Data_Exploration.ipynb
02_Fast-Gradient-Sign-Method.ipynb
03_Basic-Iterative-Method.ipynb
04_Iterative-Least-Likely-Class-Method.ipynb
05_DeepFool.ipynb
Most functions are implemented in modules which are imported into the notebooks. The modules are:
dataset
- Dataset functionshelper
- Contains functions which are used by all attack methodsfgsm
- FGSM attack specific functionsbim
- BIM attack specific functionsillm
- ILLM attack specific functions
The functions are explained in the following sections.
To follow along with the implementations we recommend to clone the repository and download the data from Kaggle.
Model
As model we use a pre-trained GoogLeNet Inception v1 model architecture Going Deeper with Convolutions. It is a 22 layer (when not counting pooling) deep neural net with inception blocks. It was trained on the ImageNet dataset and can be directly imported from the PyTorch library. In the ImageNet competition of 2014 this architecture achieved the lowest classification error in the category classification and localization with provided training data.
Data
To assess the impact of adversarial examples, a dataset with a large number of classes is preferred. The ImageNet dataset contains 1000 classes. However, instead of using the 100,000 images for testing, in this project a similar dataset is used from the NIPS 2017: Non-targeted Adversarial Attack challenge hosted on Kaggle. It consists of 1000 images and can be handled on a CPU. A Kaggle account is required to access it.
As required by the model, we scale and normalize the data:
We define the dataloader object in the module dataset
:
Module Helper
The module helper
contains functions which are not attack-method specific.