Skip to content

MetaMain/BARZ

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 

Repository files navigation

BARZ: Barrier Zones for Adversarial Example Defense

Code corresponding to the Barrier Zone (BARZ) defense paper: https://ieeexplore.ieee.org/document/9663375

In this repository we give the BARZ code and models for the CIFAR-10 dataset. We provide a PyTorch version of the code and the trained models in both PyTorch and TensorFlow.

Step by Step Guide

  1. Install the packages listed in the Software Installation Section (see below).
  2. Download the models from the Google Drive link listed in the PyTorch BARZ Models Section.
  3. Set the "modelsDir" variable on line 10 in "BarrierZoneTrainer.py" to the directory where you saved the models e.g. modelDir = "C://Users//Downloads//BARZ-8 PyTorch Models//"
  4. Open the BarrierZoneTrainer.sln file in the Python IDE of your choice. Choose one of the attack or training lines and uncomment it. Run the main.

Software Installation

We use the following software packages:

  • pytorch==1.7.1
  • torchvision==0.8.2
  • numpy==1.19.2

PyTorch BARZ Models

The trained PyTorch version of the BARZ models are available for download here.

Tensorflow BARZ Models

The original BARZ models for CIFAR-10 in TensorFlow are available for download here. While we no longer support TensorFlow implementation, the models can be loaded in TensorFlow 1.X using the following command:

model=tensorflow.keras.models.load_model(modelFileDir,  custom_objects={"tensorflow": tensorflow}) 

where "modelFileDir" is the file path of the saved model, e.g., "C://Users//BARZ-8 TensorFlow//BUZZ32_ResNet6v2_model.h5"

Code Results vs Paper Results

The results reported in the main paper were run in 2018-2020 using TensorFlow 1.12. There are several differences between the PyTorch code provided in this GitHub and the original TensorFlow code. As a consequence, the result that can be re-created with this GitHub code are not identical to the results reported in the paper. We list the main differences below:

  1. The PyTorch attack code uses a balanced dataset (i.e. an equal number of samples from each class). The original TensorFlow code used the first n correctly identified samples.
  2. The PyTorch attack code generates synthetic data using the Fast Gradient Sign Method (FGSM). The original TensorFlow code used Jacobian-based dataset augmentation.
  3. The PyTorch ResNet models are trained with different hyperparameters and different dataset augmentation techniques as compared to the ResNet models in TensorFlow/Keras.

For comparisons and follow up work, we acknowledge the legitimacy of using the PyTorch GitHub code for reporting future BARZ related results.

Credit

Our code makes use of some existing codes which we credit here. Specifically:

Contact

For questions or concerns please contact: kaleel.mahmood@uconn.edu

About

Code corresponding to the Barrier Zone (BARZ) defense paper.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages