Giter Club home page Giter Club logo

distribution-testing's Introduction

DistXplore: Distribution guided testing tool for AI models

A distribution-guided approach for generating valid test cases with diverse distributions. Unlike existing testing techniques that optimize individual test cases, DistXplore optimizes test suites that represent specific distributions. For details about DistXplore, please refer to our paper accepted in FSE 2023 and our website.

Preformace of DistXplore

Dissector and A2D are two SOTA adversarial defense techniques. The smaller the number, the stronger the ability to bypass defenses. performance

Install

  1. Clone code
git clone https://github.com/l1lk/Distribution-testing.git
cd ./Distribution-testing
  1. Install dependence python packages Install Pytorch, you can use the following command to install PyTorch version 1.13.1. For installing other versions, please refer to this.
conda install pytorch==1.13.1 torchvision==0.14.1 torchaudio==0.13.1 pytorch-cuda=11.6 -c pytorch -c nvidia

Install dependence python packages.

pip install -r requirements.txt

Usage

Quickly run

We provide a script to generate distribution-aware test cases for LeNet-5 model trained on MNIST dataset.

sh generate_demo.sh

Run on your own data and model

  1. prepare seed suite and target suite

To run on your own data, you need to prepare npy-formatted seed suite and target suite. In the seed suite, there are N samples from the same class. Taking the MNIST dataset as an example with image shape (28, 28, 1), the seed suite is an ndarray with shape (N, 28, 28, 1). The target suite is similar but the samples come from another class.

  1. prepare data preprocess function

Modify the function own_data_preprocessing() on line 28 in AttackSet.py to adapt to your dataset.

  1. Run the following command
python AttackSet.py -seeds seed_suite_file_path \
-gt groud_truth_of_seed_suite \
-target target_suite_file_path \
-target_class target_class_index \
-model model_path \
-o output_path \
-pop_num 100 \
-subtotal 50 \
-type own \
-max_iteration 30
  • seeds: the file path of prepared seed suite
  • gt: label file of prepared seed suite
  • target: the file path of prepared target suite
  • model: model path
  • o: output path
  • pop_num: Hyperparameters of GA, population size
  • subtotal: Hyperparameters of GA, number of ind in each group
  • type: run on your own data and model
  • max_iteration: Hyperparameters of GA, Number of optimization iterations
  1. Outputs
└── Distribution-testing
       ├── output_path
           ├── best_mmds
           ├── crashes
           ├── imgs
           └── plot.log
  • best_mmds: Save the individual closest to the target distribution for each epoch.
  • crashes: Save the misclassified cases generated in each epoch.
  • imgs: Crashes in PNG format.
  • plot.log: Record information for each iteration of the optimization process.

distribution-testing's People

Contributors

l1lk avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.