# Combining Contrastive Learning with Auto-Encoder for Out-of-Distribution Detection
## 1 Introduction
Moreover, the intrinsic capacity of unsupervised models to uncover hidden patterns or structures in data, which might elude supervised methods, positions them as promising OOD detectors. The models achieve this by learning what constitutes normal from the underlying data distribution. Considering this, much research has attempted to extract the compact discriminative features of in-distribution data using self-supervised methods--one type of unsupervised learning--where the models learn the representation through various agent tasks. Unluckily, the performance failed to meet the requirement because the features in latent space, learned by a deep neural network (DNN), are not separable enough to distinguish between the known and unknown. Specifically, when the number of classes is large, the performance of self-supervised learning degrades sharply. Among them, auto-encoders are widely expected to learn a good set of representations to reduce the reconstruction error. However, the input raw data contains large amounts of unnecessary information, which prevents the model from learning compact features for discrimination between the known and unknown. Recently, contrastive learning has seen significant advancements in enhancing the capability of deep neural networks to learn the crucial representations for downstream classification tasks. Based on the aforementioned analysis, the objective of this study is to address the challenge of training deep models solely on unlabeled data to endow them with robust OOD detection capabilities. This necessitates devising effective strategies to harness the potential of unlabeled datasets, enabling the deep models to discern and accurately identify OOD instances without reliance on labeled data. The core question revolves around the exploration of methodologies that empower deep-learning models for OOD detection in the absence of labeled samples, paving the way for more scalable and resource-efficient deployment in real-world applications. In this study, we introduce a novel approach that combines contrastive learning with an auto-encoder to enhance OOD detection performance. Contrastive learning works by optimizing feature extraction, pulling in-distribution samples closer together while pushing OOD samples farther apart during training. Consequently, it provides the auto-encoder with preprocessed features rather than raw data mixed with noise. Auto-encoders have the capability to model a distinct feature distribution space for each dataset, imparting specificity to the input features within the feature distribution space. Our results demonstrate that this integrated framework surpasses the performance of many existing self-supervised OOD detection methods and even competes favorably with certain supervised techniques. In summary, there are three contributions to this work: (1) We propose a simple approach to combine contrastive learning with an auto-encoder for OOD detection. The backbone network is trained with a contrastive learning method to provide an auto-encoder with processed features--the auto-encoder constructs better feature space for the discrimination of known and unknown instances. (2) Through end-to-end training, contrastive learning and the auto-encoder boost each other to improve the performance of the deep-learning model. (3) We performed experiments under various contexts. The proposed approach achieves SOTA performance on multiple public datasets.