Table of Contents
Fetching ...

Gradient-Regularized Out-of-Distribution Detection

Sina Sharifi, Taha Entesari, Bardia Safaei, Vishal M. Patel, Mahyar Fazlyab

TL;DR

This work addresses over-confident predictions in neural networks for Out-of-Distribution (OOD) detection by introducing Gradient Regularized OOD (GReg), which penalizes the gradient norm of the OOD score to capture local information, and its energy-based extension GReg+ that uses clustering to select informative OOD samples during training. The method combines a gradient-regularization term $\mathcal{L}_{\nabla S}$ with the energy-based objective, resulting in a full loss $\mathcal{L} = \mathcal{L}_{CE} + \lambda_S\mathcal{L}_S + \lambda_{\nabla S}\mathcal{L}_{\nabla S}$ and a Taylor-based intuition $S(x') \approx S(x) + \nabla S(x)^{\top}(x'-x)$ to promote local smoothness. The authors provide a theoretical basis via local Lipschitz and certified-robustness arguments and demonstrate strong empirical gains on CIFAR-10/100 and ImageNet, with GReg+ achieving state-of-the-art FPR95 and robust AUROC improvements, aided by energy-based clustering for sampling. Code is released to facilitate reproduction and adoption. Overall, the approach offers a principled way to leverage gradient information and data diversity to improve OOD robustness in practical deployments.

Abstract

One of the challenges for neural networks in real-life applications is the overconfident errors these models make when the data is not from the original training distribution. Addressing this issue is known as Out-of-Distribution (OOD) detection. Many state-of-the-art OOD methods employ an auxiliary dataset as a surrogate for OOD data during training to achieve improved performance. However, these methods fail to fully exploit the local information embedded in the auxiliary dataset. In this work, we propose the idea of leveraging the information embedded in the gradient of the loss function during training to enable the network to not only learn a desired OOD score for each sample but also to exhibit similar behavior in a local neighborhood around each sample. We also develop a novel energy-based sampling method to allow the network to be exposed to more informative OOD samples during the training phase. This is especially important when the auxiliary dataset is large. We demonstrate the effectiveness of our method through extensive experiments on several OOD benchmarks, improving the existing state-of-the-art FPR95 by 4% on our ImageNet experiment. We further provide a theoretical analysis through the lens of certified robustness and Lipschitz analysis to showcase the theoretical foundation of our work. Our code is available at https://github.com/o4lc/Greg-OOD.

Gradient-Regularized Out-of-Distribution Detection

TL;DR

This work addresses over-confident predictions in neural networks for Out-of-Distribution (OOD) detection by introducing Gradient Regularized OOD (GReg), which penalizes the gradient norm of the OOD score to capture local information, and its energy-based extension GReg+ that uses clustering to select informative OOD samples during training. The method combines a gradient-regularization term with the energy-based objective, resulting in a full loss and a Taylor-based intuition to promote local smoothness. The authors provide a theoretical basis via local Lipschitz and certified-robustness arguments and demonstrate strong empirical gains on CIFAR-10/100 and ImageNet, with GReg+ achieving state-of-the-art FPR95 and robust AUROC improvements, aided by energy-based clustering for sampling. Code is released to facilitate reproduction and adoption. Overall, the approach offers a principled way to leverage gradient information and data diversity to improve OOD robustness in practical deployments.

Abstract

One of the challenges for neural networks in real-life applications is the overconfident errors these models make when the data is not from the original training distribution. Addressing this issue is known as Out-of-Distribution (OOD) detection. Many state-of-the-art OOD methods employ an auxiliary dataset as a surrogate for OOD data during training to achieve improved performance. However, these methods fail to fully exploit the local information embedded in the auxiliary dataset. In this work, we propose the idea of leveraging the information embedded in the gradient of the loss function during training to enable the network to not only learn a desired OOD score for each sample but also to exhibit similar behavior in a local neighborhood around each sample. We also develop a novel energy-based sampling method to allow the network to be exposed to more informative OOD samples during the training phase. This is especially important when the auxiliary dataset is large. We demonstrate the effectiveness of our method through extensive experiments on several OOD benchmarks, improving the existing state-of-the-art FPR95 by 4% on our ImageNet experiment. We further provide a theoretical analysis through the lens of certified robustness and Lipschitz analysis to showcase the theoretical foundation of our work. Our code is available at https://github.com/o4lc/Greg-OOD.
Paper Structure (22 sections, 6 equations, 5 figures, 12 tables, 1 algorithm)

This paper contains 22 sections, 6 equations, 5 figures, 12 tables, 1 algorithm.

Figures (5)

  • Figure 1: Left: Effect of the local structure of the score manifold on a two-dimensional toy example for OOD detection. The grey plane depicts the score function's decision threshold. An equal amount of perturbation in these two scenarios results in different OOD detections, highlighting the importance of the local structure of the score manifold. Right: t-SNE plot showing the representation of ID and OOD datasets for CIFAR experiments.
  • Figure 2: Overview of GReg+. The gradient loss allows the method to obtain more local information from the training data. The sampling algorithm uses the normalized features of the OOD samples to perform clustering and choose the sampled data based on the energy score (see \ref{['alg:cluster']}) which will be used to calculate the gradient loss to expose the network to samples that can improve the performance of the model.
  • Figure 3: The evolution of the Energy loss and the norm of the gradient with respect to the input of the score function during training with and without gradient regularization. Gradient regularization reduces the slope of the increase of the gradient norm, without negatively affecting the reduction in energy loss. The sudden change in the behavior of the plots towards the final iterations is due to learning rate scheduling.
  • Figure 4: Distributions of energy scores. The left figure shows the distribution of the pre-trained model, the middle shows the same for Energy loss and the right figure shows the distribution for GReg.
  • Figure : Energy-Based Sampling