Code Monkey home page Code Monkey logo

deep_mahalanobis_detector's Introduction

A Simple Unified Framework for Detecting Out-of-Distribution Samples and Adversarial Attacks

This project is for the paper "A Simple Unified Framework for Detecting Out-of-Distribution Samples and Adversarial Attacks". Some codes are from odin-pytorch, LID, and adversarial_image_defenses.

Preliminaries

It is tested under Ubuntu Linux 16.04.1 and Python 3.6 environment, and requries Pytorch package to be installed:

Downloading Out-of-Distribtion Datasets

We use download links of two out-of-distributin datasets from odin-pytorch:

Please place them to ./data/.

Downloading Pre-trained Models

We provide six pre-trained neural networks (1) three DenseNets trained on CIFAR-10, CIFAR-100 and SVHN, where models trained on CIFAR-10 and CIFAR-100 are from odin-pytorch, and (2) three ResNets trained on CIFAR-10, CIFAR-100 and SVHN.

Please place them to ./pre_trained/.

Detecting Out-of-Distribution Samples (Baseline and ODIN)

# model: ResNet, in-distribution: CIFAR-10, gpu: 0
python OOD_Baseline_and_ODIN.py --dataset cifar10 --net_type resnet --gpu 0

Detecting Out-of-Distribution Samples (Mahalanobis detector)

1. Extract detection characteristics:

# model: ResNet, in-distribution: CIFAR-10, gpu: 0
python OOD_Generate_Mahalanobis.py --dataset cifar10 --net_type resnet --gpu 0

2. Train simple detectors:

# model: ResNet
python OOD_Regression_Mahalanobis.py --net_type resnet

Detecting Adversarial Samples (LID & Mahalanobis detector)

0. Generate adversarial samples:

# model: ResNet, in-distribution: CIFAR-10, adversarial attack: FGSM  gpu: 0
python ADV_Samples.py --dataset cifar10 --net_type resnet --adv_type FGSM --gpu 0

1. Extract detection characteristics:

# model: ResNet, in-distribution: CIFAR-10, adversarial attack: FGSM  gpu: 0
python ADV_Generate_LID_Mahalanobis.py --dataset cifar10 --net_type resnet --adv_type FGSM --gpu 0

2. Train simple detectors:

# model: ResNet
python ADV_Regression.py --net_type resnet

deep_mahalanobis_detector's People

Contributors

pokaxpoka avatar

Watchers

 avatar  avatar

Forkers

birajaghoshal

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.