Giter VIP home page Giter VIP logo

deepcert's Introduction

Setup

  1. The code is tested with python3 and TensorFlow v1.10 and v1.12 (TensorFlow v1.8 is not compatible). The following packages are required.
conda create --name deepcert python=3.6
source activate deepcert
conda install pillow numpy scipy pandas h5py tensorflow numba posix_ipc matplotlib
  1. Ready to run our project.
python pymain.py

It will provide the results of mnist_cnn_8layer_5_3 and lenet with sigmoid, tanh and arctan as activation function.

Results of robustness certificate and runtime are saved into log_pymain_{timestamp}.txt

How to Run

We have provided a interfacing file pymain.py to compute certified bounds. This file contains a function run_cnn that computes DeepCert bounds and runtime averaged over a given number of samples.

Usage: run_cnn(file_name, n_samples, norm, core, activation, cifar)
  • file_name: file name of network to certify
  • n_samples: number of samples to certify
  • norm: p-norm, 1,2 or i (infinity norm)
  • core: True or False, use True for networks with only convolution and pooling
  • activation: followed by a activation function of network- use ada for adaptive relu bounds (relu, ada, tanh, sigmoid or arctan)
  • cifar: True or False, uses MNIST if False

Training your own models and evaluating DeepCert.

We provide pre-trained models here. The pre-trained models use the follwing naming convention:

Pure CNN Models:

{dataset}_cnn_{number of layers}layer_{filter size}_{kernel size}[_{non ReLU activation}]
Example: mnist_cnn_4layer_10_3
Example: cifar_cnn_5layer_5_3_tanh

General CNN Models:

{dataset}_cnn_{number of layers}layer[_{non ReLU activation}]
Example: mnist_cnn_7layer
Example: mnist_cnn_7layer_tanh

Fully connected Models:

{dataset}_{number of layers}layer_fc_{layer size}
Example: mnist_2layer_fc_20

Resnet Models:

{dataset}_resnet_{number of residual blocks}[_{non ReLU activation}]
Example: mnist_resnet_3
Example: mnist_resnet_4_tanh

LeNet Models:

{dataset}_cnn_lenet[_nopool][_{non ReLU activation}]
Example: mnist_cnn_lenet_tanh
Example: mnist_cnn_lenet_nopool

If you want to run CNN-Cert, you can refer to https://github.com/AkhilanB/CNN-Cert.git. Our environment "deepcert" can also support CNN-Cert.

If you want to run FROWN, you can use cnn_to_mlp.py to transfer pure cnns to mlps, then clone the tool FROWN:

FROWN's code is tested with python 3.7.3, Pytorch 1.1.0 and CUDA 9.0. Run the following to install pytorch and its CUDA toolkit:

conda install pytorch torchvision cudatoolkit=9.0 -c pytorch

Then clone this repository:

git clone https://github.com/ZhaoyangLyu/FROWN.git
cd FROWN

Then refer to the README.md in folder "FROWN".

deepcert's People

Contributors

vivianwu0512 avatar

Stargazers

jakehuang999 avatar NWMonster 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.