# Combining Contrastive Learning with Auto-Encoder for Out-of-Distribution Detection
## 5 Results and Discussion
### Strengths of Combined Contrastive Learning and Auto-Encoder  
The performance issues associated with unsupervised learning in OOD detection are multifaceted. Unsupervised learning methods often assume that training and testing data originate from similar distributions. In OOD detection, due to the lack of labels, ensuring this assumption holds is challenging. If the distribution of test data significantly deviates from that of the training data, unsupervised learning methods may struggle to generalize effectively to unseen data. In addition, unsupervised learning models may not effectively capture the key features related to OOD samples during the learning of feature representations. This results in diminished performance for OOD data, as the model fails to distinguish effectively between known and unknown data. Thirdly, in the absence of labels, unsupervised learning methods face difficulty in learning decision boundaries conducive to OOD detection during training. Some unsupervised learning methods may overly fit the known data distribution during training, struggling to adapt to unknown data distributions that deviate significantly from the training data. This may lead to the misclassification of OOD samples. Often, addressing these challenges involves incorporating additional information during training or adopting more sophisticated model architectures to enhance the generalization of unknown data. Certainly, the combination of contrastive learning with an auto-encoder in our method addresses the aforementioned challenges in the following ways. Contrastive learning is employed to train the backbone of our model, facilitating the extraction of more robust and discriminative features. By pulling in-distribution samples closer and pushing OOD samples farther away in the learned representation space, the model becomes more adept at capturing the underlying patterns that distinguish known and unknown data. The auto-encoder component of our method contributes to the refinement of the latent space. By minimizing the reconstruction error between the input and the reconstructed output, the auto-encoder encourages the preservation of essential information in the feature space. This results in a more refined and expressive latent representation that aids in distinguishing \begin{table}
\begin{tabular}{c c c c c c c c c} \hline \hline
**In-Dis.** & **Out-Dis.** & **Ours** & **SSD** & **Sup.** & **In-Dis.** & **Out-Dis.** & **Ours** & **SSD** & **Sup.** \\ \hline \multirow{5}{*}{CIFAR-10} & CIFAR-100 & **72.4** & **90.6** & **90.6** & & CIFAR-10 & 53.4 & **69.6** & 55.3 \\  & SVHN & 99.1 & **99.6** & **99.6** & & SVHN & **97.8** & 94.9 & 94.5 \\ \cline{1-1}  & DTD & **98.9** & 97.6 & 97.8 & CIFAR-100 & DTD & 93.0 & 82.9 & **98.8** \\ \cline{1-1}  & LSUN & **99.4** & 96.5 & 93.8 & & LSUN & **96.0** & 79.5 & 69.4 \\ \cline{1-1}  & Places365 & **98.9** & 95.2 & 92.7 & & Places365 & **95.2** & 79.6 & 62.6 \\ \hline Average & & 93.7 & **95.9** & 94.9 & & & **87.1** & 81.3 & 76.1 \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Comparisons with SSD [44] and supervised-based OOD detection methods. The metric in the table is AUROC. All values are in % format. between in-distribution and OOD samples. Contrastive learning and an auto-encoder work synergistically during end-to-end training; while contrastive learning focuses on strengthening the discriminative capabilities of the model, the auto-encoder pushes for reconstruction accuracy. This complementary learning ensures that the model is well-balanced and capable of effectively discerning OOD samples. The combination of contrastive learning and an auto-encoder equips the model to handle deviations in data distribution. The enhanced feature representation and refined latent space contribute to improved generalization capabilities, allowing the model to adapt to unseen distributions during testing.