Git Product home page Git Product logo

adapt's Introduction

ADAPT

ADAPT is an open source white-box testing framework for deep neural networks, which is first introduced in Effective White-Box Testing for Deep Neural Networks with Adaptive Neuron-Selection Strategy.

Docker

ADAPT offers a docker image with pre-installed ADAPT. If you want to install docker, please see here. Instructions for GPU support for Docker can be found in here. Following command will download an image.

$ docker pull ghcr.io/kupl/adapt

You can see the downloaded image with the following command.

$ docker images
REPOSITORY              TAG                           IMAGE ID            CREATED             SIZE
ghcr.io/kupl/adapt      latest                        ...

Docker container

To open a bash using the docker image, use the following command.

$ docker run --rm -it ghcr.io/kupl/adapt bash

If no commands are pass to docker, jupyter notebook server will be launched. The command will open a server at http://localhost:8888/. If you are using a server, replace localhost with the ip address (or domain) of your server.

$ docker run -p 8888:8888 ghcr.io/kupl/adapt

Build docker image

If you want to build your docker image by yourself, the following command will download this repository and create a docker image with a tag of adapt.

$ git clone https://github.com/kupl/adapt.git
$ cd adapt
$ docker build . --tag adapt

Local Installation

If you do not prefer docker, or want to implement your own idea based on ADAPT, you can install ADAPT in your local machine. First, download this repository using git.

$ git clone https://github.com/kupl/adapt.git
$ cd adapt

ADAPT uses Tensorflow 2.0. To install Tensorflow 2.0, you need a pip>=19.0. The following commands will create a virtual environment and update pip with the Ubuntu machine. If you successfully create a virtual environment, your shell will be prefixed by (venv). Updating system pip using pip can cause some problems, so using virtual enviroment is highly recommended. More detailed instructions, including instructions about setting GPU acceleration, can be found in here.

$ sudo apt update
$ sudo apt install python3-dev python3-pip python3-venv
$ python3 -m venv --system-site-packages ./venv
$ source ./venv/bin/activate
(venv) $ pip install --upgrade pip

Install ADAPT with the following command. ADAPT will automatically install all dependancies, including tensorflow.

(venv) $ pip install .

To deactivate the virtual environment, type the following command. Then, (venv) in front of your shell will disappear.

(venv) $ deactivate

Jupyter notebook

The following command will install jupyter notebook in your virtual environment.

(venv) $ pip install notebook

To launch jupyter notebook server, type the following command.

(venv) $ jupyter notebook
# If you are using a server machine, use following command instead of above one, and visit http://(your server's ip address or domain):8888.
(venv) $ jupyter notebook --ip 0.0.0.0

If your machine have jupyter notebook installed in system-wide, you can install a kernel with the following commands.

(venv) $ pip install -I ipykernel
(venv) $ python -m ipykernel install --user --name adapt --display-name ADAPT

Now, you can see the ADAPT entry when you create a new notebook.

Tutorial

ADAPT offeres some tutorials at tutorial.

Issues

We are welcome any issues. Please, leave them in the Issues tab.

adapt's People

Contributors

henrylee97 avatar sooyoungcha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

adapt's Issues

Is ADAPT applicable to the other coverage metrics?

If I understand ADAPT correctly, it seems that it only considers two types of neuron coverage as targets to increase.

As a position interested in deep neural networks, what I am wondering is whether ADAPT is also applicable for the other coverage metrics like surprise coverage which was first introduced in ICSE `19 (Guiding deep learning system testing using surprise adequacy).

Question about experimental results on cifar10 with resnet18(test_acc:86.14%)

I pick an image for each category in CIFAR10 that predicts correctly, and metric = TKNC(30), for each image, the generation time is 15 seconds. I compare adapt and DeepXplore similarly with your tutorial, but I get poor result in adapt and good result in DeepXplore, It is normal?
Here is the result :

method total_input(10 image) total_adversarial(10 image) Labels
adapt 2047 654 20
DeepXplore 2618 2394 87

(Question from Oxford Univ) About perturbing an image

When perturbing an image, I don't think you constrain the pixel values to remain in valid ranges (e.g. for MNIST, this would be [0, 1]). I'm worried this means that many of the tests are not valid images. I've noticed this is done in DeepXplore's code as well, is this intentional? It seems like it may be unfair to test a classifier on inputs that aren't valid images.

The Result of Adapt in vgg

I tried to use test_vgg19.ipynb to run experiment for testing vgg19. But the performance is worse than the examples in the paper, such as "total adversarials" and "total inputs". But I didn't modify any files or arguments in the code of adapt.
BTW, the performance of experiment for testing mnist is the same as the examples. I don't know the reason about this problem.

the output of code "archives_adapt[0].summary()" in my testing:
`
Total inputs: 10
Average distance: 0.001166449161246419
Total adversarials: 0
Average distance: -
Coverage
Original: 0.04568829113924051
Achieved: 0.04720464135021097

Original label: Pomeranian
Count: 414
Average distance: 0.016496244817972183

Total inputs: 413
Average distance: 0.002656622789800167
Total adversarials: 0
Average distance: -
Coverage
Original: 0.04562236286919831
Achieved: 0.05195147679324894
`

And the example is:

`
Total inputs: 8471
Average distance: 0.02087555266916752
Total adversarials: 1135
Average distance: 0.0999956950545311
Coverage
Original: 0.04555643459915612
Achieved: 0.15928270042194093

Original label: Pomeranian
Count: 7336
Average distance: 0.008634363301098347

Label: hyena
Count: 217
Average distance: 0.05843096598982811

Label: meerkat
Count: 255
Average distance: 0.07762718945741653

Label: tick
Count: 224
Average distance: 0.10655633360147476

Label: guinea_pig
Count: 33
Average distance: 0.09237903356552124

Label: English_setter
Count: 44
Average distance: 0.10023358464241028

Label: Petri_dish
Count: 6
Average distance: 0.10553994029760361

Label: flatworm
Count: 343
Average distance: 0.14118780195713043

Label: shower_cap
Count: 13
Average distance: 0.04866204783320427
`

(Question from Oxford Univ) About calculating neuron coverage

When calculating neuron coverage, I had initially expected that each element of the full activation tensor of a layer would be a neuron. However, adapt/network/network.py line 69, you take a tensor of dimensions HxWxC and turn it into a vector of dimension C by flattening and taking the mean of the first two dimensions. I believe DeepXplore does this as well, but I'm not sure I understand why this is?

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.