Paper: Towards Optimal Feature-Shaping Methods for Out-of-Distribution Detection (ICLR-2024)

Reviewer comment (Experiments):
I am curious about the comparison of the proposed method with the methods that can train with the real outliers in different benchmarks.

Author response:
We sincerely thank you for the time and effort you invested in reviewing our paper.  We are grateful for your acknowledgment of its well-crafted composition, the significance of the problem it addresses, and its demonstration of superior results compared to current state-of-the-art methods.

We compare our proposed method and others, including training a model with outlier exposure and using contrastive learning objectives. These training methods are not designed for a large-scaled dataset like ImageNet-1k. Thus, our experiments are conducted on the ImageNet-200 benchmark with ResNet18, following OpenOOD V1.5 [1]. 

We emphasize that this is not a fair comparison, because our method is designed for post-hoc OOD detection, assuming no access to OOD data and no extra model training process. But as shown in the table, there are no significant differences between different methods. Training methods do not show a significant advantage over the post-hoc methods, as also observed by OpenOOD V1.5 [1].

Due to the time constraints associated with the rebuttal, we are currently unable to carry out very extensive experiments to compare post-hoc OOD methods with training methods. However, exploring the performance of training methods across various benchmarks and model architectures is a promising direction that we look forward to investigating.

| Training                    | OOD Score | ID Accuracy                       | AUC (Near OOD) | AUC (Far OOD) | AUC (Mean)   |
| --------------------------- | --------- | --------------------------------- | -------------- | ------------- | ------------ |
| **- Post-hoc**              |           |                                   |                |               |              |
| CrossEntropy                | MSP       | 86.37                             | *83.29*   | 90.13         | 86.71        |
| CrossEntropy                | Energy    | 86.37                             | 82.41          | 90.84         | 86.62        |
| CrossEntropy                | ReAct     | 86.37                             | 81.77          | 92.28         | 87.03        |
| CrossEntropy                | ASH-B     | 86.37                             | 81.60          | *93.77*  | *87.68* |
| CrossEntropy                | Ours      | 86.37                             | 81.16          | 92.80         | 86.98        |
| **- Training w/o outliers** |           |                                   |                |               |              |
| ConfBranch (arXiv’18)       |           | 85.92                             | 79.10          | 90.43         | 84.77        |
| RotPred (NeurIPS’19)        |           | 86.37                             | 81.59          | 92.56         | *87.08* |
| G-ODIN (CVPR’20)            |           | 84.56                             | 77.28          | 92.33         | 84.81        |
| CSI (NeurIPS’20)            |           | Infeasible with compute resources | /              | /             |              |
| ARPL (TPAMI’21)             |           | 83.95                             | 82.02          | 89.23         | 85.62        |
| MOS (CVPR’21)               |           | 85.60                             | 69.84          | 80.46         | 75.15        |
| VOS (ICLR’22)               |           | 86.23                             | 82.51          | 91.00         | 86.75        |
| LogitNorm (ICML’22)         |           | 86.04                             | 82.66          | *93.04*  | **87.85**    |
| CIDER (ICLR’23)             |           | No final linear classifier        | 80.58          | 90.66         | 85.62        |
| NPOS (ICLR’23)              |           | No final linear classifier        | 79.40          | **94.49**     | 86.94        |
| **- Training w/ outliers**  |           |                                   |                |               |              |
| OE (NeurIPS’18)             |           | 85.82                             | **84.84**      | 89.02         | 86.93        |
| MCD (ICCV’19)               |           | 86.12                             | *83.62*   | 88.94         | 86.28        |
| UDG (ICCV’21)               |           | 68.11                             | 74.30          | 82.09         | 78.19        |
| MixOE (WACV’23)             |           | 85.71                             | 82.62          | 88.27         | 85.44        |

**Bold** numbers are superior results whereas *Italic* numbers denote the second and third best results.

[1] Zhang, Jingyang, et al. "OpenOOD v1. 5: Enhanced Benchmark for Out-of-Distribution Detection." *arXiv preprint arXiv:2306.09301* (2023).

Reviewer comment (Experiments):
In terms of the feature-shaping methods, I am curious how well the proposed method compared to the OOD detection using contrastive learning objectives to reshape the feature, such as CSI and SSD [2] on different benchmarks and mode architectures.

Author response:
We sincerely thank you for the time and effort you invested in reviewing our paper.  We are grateful for your acknowledgment of its well-crafted composition, the significance of the problem it addresses, and its demonstration of superior results compared to current state-of-the-art methods.

We compare our proposed method and others, including training a model with outlier exposure and using contrastive learning objectives. These training methods are not designed for a large-scaled dataset like ImageNet-1k. Thus, our experiments are conducted on the ImageNet-200 benchmark with ResNet18, following OpenOOD V1.5 [1]. 

We emphasize that this is not a fair comparison, because our method is designed for post-hoc OOD detection, assuming no access to OOD data and no extra model training process. But as shown in the table, there are no significant differences between different methods. Training methods do not show a significant advantage over the post-hoc methods, as also observed by OpenOOD V1.5 [1].

Due to the time constraints associated with the rebuttal, we are currently unable to carry out very extensive experiments to compare post-hoc OOD methods with training methods. However, exploring the performance of training methods across various benchmarks and model architectures is a promising direction that we look forward to investigating.

| Training                    | OOD Score | ID Accuracy                       | AUC (Near OOD) | AUC (Far OOD) | AUC (Mean)   |
| --------------------------- | --------- | --------------------------------- | -------------- | ------------- | ------------ |
| **- Post-hoc**              |           |                                   |                |               |              |
| CrossEntropy                | MSP       | 86.37                             | *83.29*   | 90.13         | 86.71        |
| CrossEntropy                | Energy    | 86.37                             | 82.41          | 90.84         | 86.62        |
| CrossEntropy                | ReAct     | 86.37                             | 81.77          | 92.28         | 87.03        |
| CrossEntropy                | ASH-B     | 86.37                             | 81.60          | *93.77*  | *87.68* |
| CrossEntropy                | Ours      | 86.37                             | 81.16          | 92.80         | 86.98        |
| **- Training w/o outliers** |           |                                   |                |               |              |
| ConfBranch (arXiv’18)       |           | 85.92                             | 79.10          | 90.43         | 84.77        |
| RotPred (NeurIPS’19)        |           | 86.37                             | 81.59          | 92.56         | *87.08* |
| G-ODIN (CVPR’20)            |           | 84.56                             | 77.28          | 92.33         | 84.81        |
| CSI (NeurIPS’20)            |           | Infeasible with compute resources | /              | /             |              |
| ARPL (TPAMI’21)             |           | 83.95                             | 82.02          | 89.23         | 85.62        |
| MOS (CVPR’21)               |           | 85.60                             | 69.84          | 80.46         | 75.15        |
| VOS (ICLR’22)               |           | 86.23                             | 82.51          | 91.00         | 86.75        |
| LogitNorm (ICML’22)         |           | 86.04                             | 82.66          | *93.04*  | **87.85**    |
| CIDER (ICLR’23)             |           | No final linear classifier        | 80.58          | 90.66         | 85.62        |
| NPOS (ICLR’23)              |           | No final linear classifier        | 79.40          | **94.49**     | 86.94        |
| **- Training w/ outliers**  |           |                                   |                |               |              |
| OE (NeurIPS’18)             |           | 85.82                             | **84.84**      | 89.02         | 86.93        |
| MCD (ICCV’19)               |           | 86.12                             | *83.62*   | 88.94         | 86.28        |
| UDG (ICCV’21)               |           | 68.11                             | 74.30          | 82.09         | 78.19        |
| MixOE (WACV’23)             |           | 85.71                             | 82.62          | 88.27         | 85.44        |

**Bold** numbers are superior results whereas *Italic* numbers denote the second and third best results.

[1] Zhang, Jingyang, et al. "OpenOOD v1. 5: Enhanced Benchmark for Out-of-Distribution Detection." *arXiv preprint arXiv:2306.09301* (2023).

Reviewer comment (Novelty):
What is the motivation to introduce ISFI? For example, ReAct [A] observes the distribution of per-unit activation for In and out-distribution data.

Author response:
> **Q1: What is the motivation to introduce ISFI?**

We aim to optimize the multiplicative function $\theta(z)$ in Eq. 4, which models elementwise feature-shaping functions. The primary challenge arises from the continuous nature of the feature value $z$, complicating the optimization problem. To address this, we introduce ISFI, a strategic discretization facilitating the assessment of feature importance for OOD detection. Specifically, we partition the domain of features into a disjoint set of intervals, which allows us to approximate the original function $\theta(z)$ with a piece-wise constant function, thus simplifying the optimization problem.

Reviewer comment (Experiments):
theta is optimized over the proposed optimization problem that the closed form exists. However, other feature shaping methods [A, B] do not have the other parameters to be optimized.

Author response:
> **Q3: Other feature shaping methods such as ReAct and ASH do not have other parameters to be optimized.**

We respectfully argue that this point actually leads to a disadvantage of ReAct and ASH compared with our method. The shaping functions of ReAct and ASH are manually designed for specific model architectures and OOD datasets. This eliminates the need for additional parameters but consequently limit their generalization ability. In contrast, while our shaping function introduces more parameters, it can be efficiently optimized in closed form based on different models and ID data. Additional parameters do not increase user burden; instead, they bring greater flexibility and generalization ability to our method (Tables 1&2).

Reviewer comment (Novelty):
Other feature shaping methods [A, B] said that their methods have comparable performance in distribution distribution after applying their methods. Can authors discuss this point?

Author response:
> **Q4: Can authors discuss the comparable performance claimed by ReAct and ASH?**

There might be some typos in your comment. Here we discuss the generalization ability claimed by ReAct and ASH over different distributions. Please engage with us in discussion if your comment is asking something different.

The experiments conducted in the ReAct and ASH papers involve a narrower range of models and OOD datasets compared to our study. This limitation restricts the evaluation on the generalization ability of their methods. 

For instance, when using ImageNet-1k as the ID data, both ReAct and ASH restrict their experiments to two model architectures and four OOD datasets. In contrast, our research encompasses a more extensive evaluation, employing eight different model architectures and eight OOD datasets. Note that the models and OOD datasets used in the ReAct and ASH studies are also included in our experimental setup.

This broader scope in our study allows for a more robust assessment of the generalization ability of our method, significantly contributing to the reliability and applicability of our findings.

Reviewer comment (Evaluation):
The reviewer didn't see any discussion or analysis about the robustness of the proposed method to thresholding. Adding this analysis would make the paper more complete.

Author response:
> **Q1: Is there any discussion or analysis about the robustness of the proposed method to thresholding.**

There are two thresholds in the paper. One is the threshold for classifying ID and OOD samples based on OOD scores. Note that AUC already reflects performance robustness across all thresholds. The other pertains to setting feature value limits for optimizing our shaping function, as detailed in Section 3.1. Here we discuss the robustness of our method to the latter.

Given that feature distributions typically exhibit long-tailed characteristics, we select the 0.1 and 99.9 percentiles of all features in a training set as the lower and upper limits of feature values, respectively, to optimize our shaping function. Here we validate different choices of percentiles on the performance of our method, on the ImageNet-1k benchmark with ResNet50. The results are shown as follows:

| Lower percentile | Lower limit | Upper percentile | Upper limit | FPR95     | AUC       |
| ---------------- | ----------- | ---------------- | ----------- | --------- | --------- |
| 0.0              | 0.00        | 100.0            | 20.65       | 42.42     | 87.90     |
| 0.01             | 0.00        | 99.99            | 5.64        | 42.22     | 87.97     |
| 0.05             | 0.00        | 99.95            | 4.40        | 41.97     | 88.04     |
| 0.1              | 0.00        | 99.9             | 3.88        | 41.82     | 88.11     |
| 0.5              | 0.00        | 99.5             | 2.74        | 41.01     | 88.44     |
| 1.0              | 0.00        | 99.0             | 2.28        | **41.00** | **88.50** |
| 5.0              | 0.03        | 95.0             | 1.35        | 47.85     | 86.41     |
| 10.0             | 0.06        | 90.0             | 1.01        | 57.45     | 83.60     |

Our method exhibits a insensitivity to the chooses of lower and upper limits. Although in the main experiments (Tables 1 & 2) we consistently use the 0.1 and 99.9 percentiles, exploring alternate settings reveals potential for slight improvements. 

These experiments will be incorporated into the revised paper if space allows or updated in the Supplementary Material.

Reviewer comment (Theory):
The reviewer believes that further explanation is needed as to why $E_{x^{OOD} \sim D^{OOD}_{\chi}} [I (Z^{OOD}) ]$ can be ignored. The explanation in Fig. 3 is still not convincing enough.

Author response:
> **Q2: Further explanation is needed as to why $E_{\boldsymbol{x}^{\text{OOD}}\sim D_{\cal X}^{\text{OOD}}}\left[{\boldsymbol{I}(\boldsymbol{z}^{\text{OOD}})}\right]$ can be ignored.** 

In the general setting where we have no prior knowledge about the OOD data encountered during deployment, the distribution of $\boldsymbol{I}(\boldsymbol{z}^{\text{OOD}})$ is unknown, rendering the problem in Eq. 12 intractable. However, if we ignore the unknown term $E_{\boldsymbol{x}^{\text{OOD}}\sim D_{\cal X}^{\text{OOD}}}\left[{\boldsymbol{I}(\boldsymbol{z}^{\text{OOD}})}\right]$, Eq. 12 can be easily solved in closed form and our method shows improved performance for OOD detection. We have some possible working theories on why we can just ignore it (Fig. 3), which are supported by the experiments (Section 4.2).

Our working explanation is based on the similarities or differences in feature representations between these two types of samples.

1. **In the Case of Hard OOD (High Similarity to ID)**: When OOD samples closely resemble ID samples, their feature representations tend to align. This similarity implies that the expectations we calculate for both OOD and ID samples point in similar directions. 
2. **In the Case of Easy OOD (Divergence from ID)**: Conversely, when OOD samples are markedly different from ID samples, the maximum logits (a measure of model confidence) for these OOD samples are typically lower. This lower confidence translates to a reduced magnitude of the expectation value for OOD samples compared to ID samples. 

Thus, the aspect of $E_{\boldsymbol{x}^{\text{OOD}}\sim D_{\cal X}^{\text{OOD}}}\left[{\boldsymbol{I}(\boldsymbol{z}^{\text{OOD}})}\right]$ that is orthogonal to the ID expectation is minimal, and the term can be ignored with a small affect on the optimized results.

If there are specific concerns or areas that seem unclear, please highlight them and engage with us in the discussion for a more targeted explanation.

Reviewer comment (Writing):
Is there a more intuitive explanation for this method that would make it more understandable?

Author response:
> **Q3: Is there a more intuitive explanation for this method that would make it more understandable?**

Thank you for your question. We write a new explanation, trying to make it easy to understand and planning to revise the paper accordingly. If certain aspects or points are not entirely clear or if you have particular concerns, please point them out for a more focused clarification.

Feature-shaping methods for OOD detection aims to reshape feature representations to better differentiate between ID and OOD samples. Existing methods usually employ shaping functions manually designed for specific model architectures and OOD datasets. In this paper, we want to explore "what feature-shaping function is optimal for OOD detection", focusing on element-wise feature-shaping functions like ReAct. We model this as an optimization problem - optimize the shaping function to maximize an objective function designed for OOD detection. To make the optimization problem tractable, we do two simplifications. The first is to make the shaping function piecewise constant. The second is to use a optimization objective function without OOD terms based on some working theories. The two simplifications lead to a close form solution and both are validated by experiments. Our method improves the generalization ability of OOD detection across a large variety of datasets and model architectures.

Reviewer comment (Reproducibility):
Will the code and data be open source?

Author response:
> **Q4: Will the code and data be open source?**

Yes. We have included our code as supplementary material alongside this submission. We are also committed to releasing the code on GitHub upon the official acceptance of our paper. Additionally, all the data utilized in our experiments is already open-sourced. To further assist, we will be adding a tutorial in our code repository, detailing the preparation process for the data.