# Combining Contrastive Learning with Auto-Encoder for Out-of-Distribution Detection
## 4 Experiments
### Implementation Details  
The backbone of the proposed method is based on the ResNet50 model, and the training schema is followed by the contrastive learning method called SimCLR [42]. The auto-encoder contains four MLP layers. Both the encoder and decoder have two MLP layers, where the first MLP layer is followed by a ReLU activation function. The dimensionality of the backbone is 2048. The hidden and latent dimensionalities of the encoder are 1024 and 512, respectively. The experiments are conducted on three NVIDIA GTX 3090 GPUs, and the batch size of each GPU is 512. The weight value of the loss is set as 0.3, and the optimizer is SGD. The initial learning rate is set as 1.8 and decreases with the cosine decay schedule. There is a linear warmup for 20 epochs, which continues training until 300 epochs. The threshold of the decision score is set at a true positive rate of 0.95. The datasets used in this paper are summarized as follows:* **CIFAR-10** dataset. This dataset consists of 50,000 training images and 10,000 test images from 10 different classes. Each image size is 32 \(\times\) 32 pixels. * **CIFAR-100** dataset. It also has 50,000 training images and 10,000 test images. However, it has 100 classes, which are further organized into 20 sub-classes. * **SVHN** dataset. SVHN is a real-world street-view housing number dataset. It has 73,257 digits available for training and 26,032 digits for testing. Similar to the CIFAR-10/100 dataset, the size of its image is also 32 \(\times\) 32 pixels. * **DTD** dataset. DTD is a collection of texture images in the wild. It includes a total of 5640 images, split equally between 47 categories, where the size of images ranges between 300 \(\times\) 300 and 640 \(\times\) 640 pixels. * **LSUN** dataset. The LSUN classification dataset contains 10 scene categories, such as dining room, bedroom, chicken, outdoor church, and so on. For training data, each category contains many images, ranging from around 120,000 to 3,000,000. The validation data includes 300 images, and the test data has 1000 images for each category. * **Place365** dataset. It is a scene recognition dataset, which is composed of 10 million images comprising 434 scene classes. * **iNaturalist** dataset. It contains 675,170 training and validation images from 5089 natural fine-grained categories. These categories belong to 13 super-categories, including Plantae (Plant), Insecta (Insect), Aves (Bird), Mammalia (Mammal), and so on. The iNat dataset is highly imbalanced with dramatically different numbers of images per category. We leveraged three common metrics, including FPR at TPR = 95%, AUROC, and AUPR, to evaluate our method. The false positive rate (FPR), a commonly used metric in OOD detection, measures the proportion of negative instances that are incorrectly classified as positive. FPR is calculated as follows:  
\[\text{FPR}=\frac{\text{False}\,\text{Positives}}{\text{False}\,\text{Positives} +\text{True}\,\text{Negatives}}. \tag{6}\]  
where false positives are the number of negative instances incorrectly classified as positive, and true negatives are the number of negative instances correctly classified as negative. FPR is often used in combination with other metrics like the true positive rate (TPR) to evaluate the overall performance of a classification model. In the context of OOD detection, a good OOD detection model should have a low FPR, as it indicates a low rate of falsely identifying normal in-distribution samples as an OOD distribution. Reducing the FPR while maintaining high sensitivity (TPR) is a key objective for such models. AUROC stands for the area under the receiver operating characteristic curve, which is a graphical representation of model performance, as its discrimination threshold varies. In OOD detection, it can summarize the model's ability to distinguish between positive and negative samples across different threshold values. A higher AUROC indicates that the model can effectively differentiate between in-distribution and OOD samples.