Skip to content

Tensorflow Implementation of various post hoc OOD detectors

Notifications You must be signed in to change notification settings

tpoppo/ood-post-hoc

Repository files navigation

OOD post hoc methods

codecov

A TensorFlow implementation of various post hoc OOD detectors. All the methods should be compatible with the vast majority of TensorFlow models.

Usage

import tensorflow as tf
from ood_detector.detectors import MSPDetector

model = tf.keras.applications.EfficientNetB0()
detector = MSPDetector(model)
ood_score = detector.predict(x_imgs)

Methods

MSP score [1]

The maximum softmax probability proposed in "Hendrycks and K. Gimpel. A baseline for detecting misclassified and out-of-distribution examples in neural networks, 2016".

ODIN [2]

The ODIN scoring function proposed in "S. Liang, Y. Li, and R. Srikant. Enhancing the reliability of out-of-distribution image detection in neural networks, 2017".

Energy-based score [3]

The energy-based score proposed in "W. Liu, X. Wang, J. D. Owens, and Y. Li. Energy-based out-of-distribution detection, 2020".

ReAct [4]

The ReAct layer proposed in "Y. Sun, C. Guo, and Y. Li. React: Out-of-distribution detection with rectified activations, 2021".

GradNorm [5]

The GradNorm score proposed in "R. Huang, A. Geng, and Y. Li. On the importance of gradients for detecting distributional shifts in the wild".

Project Structure

  1. example.ipynb shows an example of how to use the various functions
  2. evaluation notebook contains the notebooks used for the evaluation

About

Tensorflow Implementation of various post hoc OOD detectors

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published