Giter Site home page Giter Site logo

jxzhangjhu / informative-outlier-mining Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jfc43/informative-outlier-mining

0.0 0.0 0.0 2.7 MB

We propose a theoretically motivated method, Adversarial Training with informative Outlier Mining (ATOM), which improves the robustness of OOD detection to various types of adversarial OOD inputs and establishes state-of-the-art performance.

License: Apache License 2.0

Python 98.66% Shell 1.34%

informative-outlier-mining's Introduction

Informative Outlier Matters: Robustifying Out-of-distribution Detection Using Outlier Mining

This project is for the paper: Informative Outlier Matters: Robustifying Out-of-distribution Detection Using Outlier Mining. Some codes are from ODIN, Outlier Exposure, Deep Mahalanobis Detector, Corruption and Perturbation Robustness and Certified Certain Uncertainty.

Illustration

ATOM banner

Experimental Results

Main Results

Preliminaries

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

Downloading In-distribution Dataset

  • SVHN: need to download Format 2 data.
  • CIFAR: included in PyTorch.

Downloading Auxiliary OOD Datasets

cd datasets/unlabeled_datasets/80M_Tiny_Images
wget http://horatio.cs.nyu.edu/mit/tiny/data/tiny_images.bin

Downloading Out-of-distribution Test Datasets

We provide links and instructions to download each dataset:

  • SVHN: download it and place it in the folder of datasets/ood_datasets/svhn. Then run python select_svhn_data.py to generate test subset.
  • Textures: download it and place it in the folder of datasets/ood_datasets/dtd.
  • Places365: download it and place it in the folder of datasets/ood_datasets/places365/test_subset. We randomly sample 10,000 images from the original test dataset. We provide the file names for the images that we sample in datasets/ood_datasets/places365/test_subset/places365_test_list.txt.
  • LSUN-C: download it and place it in the folder of datasets/ood_datasets/LSUN.
  • LSUN-R: download it and place it in the folder of datasets/ood_datasets/LSUN_resize.
  • iSUN: download it and place it in the folder of datasets/ood_datasets/iSUN.

For example, run the following commands in the root directory to download LSUN-C:

cd datasets/ood_datasets
wget https://www.dropbox.com/s/fhtsw1m3qxlwj6h/LSUN.tar.gz
tar -xvzf LSUN.tar.gz

Downloading Pre-trained Models

We provide pre-trained DenseNet models for vanilla, SOFL, OE, ACET, CCU, ROWL, NTOM, and ATOM methods on SVHN, CIFAR-10, and CIFAR-100 datasets using TinyImages as auxiliary OOD dataset. We also provide pre-trained WideResNet models for vanilla, NTOM, and ATOM methods on SVHN, CIFAR-10, and CIFAR-100 datasets using TinyImages as auxiliary OOD dataset. They can be downloaded from Google Drive.

Overview of the Code

Running Experiments

  • select_svhn_data.py: select SVHN test data.
  • eval_ood_detection.py: evaluate OOD detection performance of models.
  • compute_metrics.py: compute metrics of evaluation results.
  • gen_rowl_train_data.py: generate ROWL training data.
  • gen_validation_data.py: generate validation data used to select the best q.
  • train_acet.py: train ACET model.
  • train_atom.py: train ATOM model.
  • train_ccu.py: train CCU model.
  • train_oe.py: train OE model.
  • train_rowl.py: train ROWL model.
  • train_sofl.py: train SOFL model.
  • train.py: train vanilla model.
  • tune_mahalanobis_hyperparams.py: tune hyperparameters of Mahalanobis detector.
  • tune_odin_hyperparams.py: tune hyperparameters of ODIN detector.

Example

For CIFAR-10 experiments, you can run the following script to get the results:

./run_all_cifar10_exps.sh

To evaluate an OOD detection method, you can use the following command:

python eval_ood_detection.py --in-dataset {in-distribution dataset} --name {model name} --method {scoring function} [--adv or --corrupt or --adv-corrupt]

The argument --adv is to evaluate L_inf OOD, --corrupt is to evaluate Corrupted OOD, --adv-corrupt is to evaluate Comp. OOD. You can only specify one of them. Without them, it will evaluate natural OOD.

{in-distribution dataset} can be SVHN, CIFAR-10 or CIFAR-100.

{scoring function} can be msp, odin, mahalanobis, sofl, rowl, ntom or atom.

{model name} is the name of the model that you have trained. The model type should match the corresponding scoring function. See the following table for the matchings:

Model Type Scoring Function
vanilla msp
vanilla odin
vanilla mahalanobis
SOFL sofl
OE msp
ACET msp
CCU msp
ROWL rowl
NTOM ntom
ATOM atom

Citation

Please cite our work if you use the codebase:

@article{chen2020informative-outlier-matters,
title={Informative Outlier Matters: Robustifying Out-of-distribution Detection Using Outlier Mining},
author={Chen, Jiefeng and Li, Yixuan and Wu, Xi and Liang, Yingyu and Jha, Somesh},
journal={arXiv preprint arXiv:2006.15207},
year={2020}
}

License

Please refer to the LICENSE.

informative-outlier-mining's People

Contributors

jfc43 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.