Skip to content

Layer Adaptive Out-of-distribution Detection for Deep Neural Networks

Notifications You must be signed in to change notification settings

GM-git-dotcom/LA-OOD

 
 

Repository files navigation

LA-OOD

This is a pytorch implementation for LA-OOD: Layer Adaptive Deep Neural Networks for Out-of-distribution Detection.

Overview

Overview

An overview of our proposed Layer Adaptive Deep Neural Networks for OOD Detection (LA-OOD). As the deeper layers of a DNN tend to have higher capacity for representing more sophisticated concepts, our framework fully utilizes the intermediate outputs of a DNN to identify OODs of different complexity. Average pooling is done to first reduce the feature dimension of the intermediate outputs, then the low-dimension feature vectors are fed into the OOD detectors to generate OOD scores for the input samples. The OOD detectors are trained in an unsupervised self-adaptive setting, hence LA-OOD can be flexibly applied to any existing DNNs with minor computation and data cost.

Requirements

  • Pyhton 3.7.5
  • Pytorch 1.9.0
  • CUDA 10.1

Please use the following codes to install the full requirements:

pip install -r requirements.txt

Pre-trained models

Model CIFAR10 CIFAR100
VGG 93.94% 74.13%
DenseNet 95.06% 77.18%
ResNet 94.67% 75.02%

Running the codes

1. Train the backbone models

If you wish to train a new backbone model, run the following:

python train_backbone_model.py --model vgg16 --dataset cifar10

for the backbone models, choose from:

  • vgg16
  • resnet34
  • densenet100

for the training dataset, choose from:

  • cifar10
  • cifar100

2. Download the OOD datasets

Download the following datasets:

save the unzipped files in ./data folder

3. Generate all the datasets

Generate the InD and OOD datasets:

python generate_datasets.py

4. Save the intermedia outputs

python save_inter_outputs.py --model vgg16 --ind cifar10

5. Train OOD detectors

python train_ood_detectors.py --model vgg16 --ind cifar10

6. Test: OOD detection

python detect_oods.py --model vgg16 --ind cifar10

7. Co-train models (optional)

python co_train.py --model vgg16 --dataset cifar10

About

Layer Adaptive Out-of-distribution Detection for Deep Neural Networks

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%