Table of Contents
Fetching ...

Low-Dimensional Gradient Helps Out-of-Distribution Detection

Yingwen Wu, Tao Li, Xinwen Cheng, Jie Yang, Xiaolin Huang

TL;DR

This work addresses OOD detection by leveraging backward gradient information, arguing that gradient directions contain discriminative cues beyond gradient norms. It introduces two low-dimensional gradient representations—a PCA-based gradient subspace and an average-gradient subspace—and projects gradients via $G_{low}=GV$ to enable efficient downstream scoring. The approach integrates with forward-based scores (e.g., MSP, Energy), rectification and distance-based methods, and also employs an ensemble of forward and backward information, yielding strong improvements on ImageNet with ResNet50 and CIFAR-10 across multiple architectures. Empirical results show significant reductions in FPR95 and improvements in AUROC, with manageable time overhead and potential for parallelization, indicating practical viability for robust OOD detection in real-world systems.

Abstract

Detecting out-of-distribution (OOD) samples is essential for ensuring the reliability of deep neural networks (DNNs) in real-world scenarios. While previous research has predominantly investigated the disparity between in-distribution (ID) and OOD data through forward information analysis, the discrepancy in parameter gradients during the backward process of DNNs has received insufficient attention. Existing studies on gradient disparities mainly focus on the utilization of gradient norms, neglecting the wealth of information embedded in gradient directions. To bridge this gap, in this paper, we conduct a comprehensive investigation into leveraging the entirety of gradient information for OOD detection. The primary challenge arises from the high dimensionality of gradients due to the large number of network parameters. To solve this problem, we propose performing linear dimension reduction on the gradient using a designated subspace that comprises principal components. This innovative technique enables us to obtain a low-dimensional representation of the gradient with minimal information loss. Subsequently, by integrating the reduced gradient with various existing detection score functions, our approach demonstrates superior performance across a wide range of detection tasks. For instance, on the ImageNet benchmark with ResNet50 model, our method achieves an average reduction of 11.15$\%$ in the false positive rate at 95$\%$ recall (FPR95) compared to the current state-of-the-art approach. The code would be released.

Low-Dimensional Gradient Helps Out-of-Distribution Detection

TL;DR

This work addresses OOD detection by leveraging backward gradient information, arguing that gradient directions contain discriminative cues beyond gradient norms. It introduces two low-dimensional gradient representations—a PCA-based gradient subspace and an average-gradient subspace—and projects gradients via to enable efficient downstream scoring. The approach integrates with forward-based scores (e.g., MSP, Energy), rectification and distance-based methods, and also employs an ensemble of forward and backward information, yielding strong improvements on ImageNet with ResNet50 and CIFAR-10 across multiple architectures. Empirical results show significant reductions in FPR95 and improvements in AUROC, with manageable time overhead and potential for parallelization, indicating practical viability for robust OOD detection in real-world systems.

Abstract

Detecting out-of-distribution (OOD) samples is essential for ensuring the reliability of deep neural networks (DNNs) in real-world scenarios. While previous research has predominantly investigated the disparity between in-distribution (ID) and OOD data through forward information analysis, the discrepancy in parameter gradients during the backward process of DNNs has received insufficient attention. Existing studies on gradient disparities mainly focus on the utilization of gradient norms, neglecting the wealth of information embedded in gradient directions. To bridge this gap, in this paper, we conduct a comprehensive investigation into leveraging the entirety of gradient information for OOD detection. The primary challenge arises from the high dimensionality of gradients due to the large number of network parameters. To solve this problem, we propose performing linear dimension reduction on the gradient using a designated subspace that comprises principal components. This innovative technique enables us to obtain a low-dimensional representation of the gradient with minimal information loss. Subsequently, by integrating the reduced gradient with various existing detection score functions, our approach demonstrates superior performance across a wide range of detection tasks. For instance, on the ImageNet benchmark with ResNet50 model, our method achieves an average reduction of 11.15 in the false positive rate at 95 recall (FPR95) compared to the current state-of-the-art approach. The code would be released.
Paper Structure (27 sections, 17 equations, 8 figures, 13 tables, 4 algorithms)

This paper contains 27 sections, 17 equations, 8 figures, 13 tables, 4 algorithms.

Figures (8)

  • Figure 1: Illustration of our framework using low-dimensional gradients for OOD detection. Firstly, we obtain the parameter gradients from a complete backpropagation process of our model. Then, using a pre-extracted subspace where the principal components of training data gradients reside, we obtain low-dimensional representations through a projection operation. Finally, we feed the representations into the detection branch, where diverse score functions are designed based on these representations.
  • Figure 2: Visualization of penultimate features (left) and low-dimensional gradients (right) via t-SNE van2008visualizing. The model is trained with ResNet18 on CIFAR10.
  • Figure 3: Density distribution of low-dimensional gradients on CIFAR10 and ImageNet on different dimensions. Top left: The 9th dimension of our reduced gradient on CIFAR10. Top right: The 11th dimension on CIFAR10. Bottom left: The 1th dimension on ImageNet. Bottom right: The 999th dimension on ImageNet. These plots reveal that the distribution differences between ID and OOD data is more distinguishable on the later dimensions.
  • Figure 4: Density distribution of features (left) and low-dimensional gradients (right) of two samples (one is OOD data from Places and the other is ID data from ImageNet). We can observe that the distinction between the two samples is marginal in the feature space but significant in the gradient space.
  • Figure 5: Comparison with ODIN odin, GradNorm gradnorm and Vim vim methods on CIFAR10 with ResNet18 model (left) and ImageNet with ResNet50 model (right).
  • ...and 3 more figures