Out-of-distribution (OOD) detection is essential when deploying neural networks in the real world. One main challenge is that neural networks often make overconfident predictions on OOD data. In this study, we propose an effective post-hoc OOD detection method based on a new feature masking strategy and a novel logit smoothing strategy. Feature masking determines the important features at the penultimate layer for each in-distribution (ID) class based on the weights of the ID class in the classifier head and masks the rest features. Logit smoothing computes the cosine similarity between the feature vector of the test sample and the prototype of the predicted ID class at the penultimate layer and uses the similarity as an adaptive temperature factor on the logit to alleviate the network's overconfidence prediction for OOD data. With these strategies, we can reduce feature activation of OOD data and enlarge the gap in OOD score between ID and OOD data. Extensive experiments on multiple standard OOD detection benchmarks demonstrate the effectiveness of our method and its compatibility with existing methods, with new state-of-the-art performance achieved from our method. The source code will be released publicly.
翻译:分布外检测对于神经网络在现实世界中的部署至关重要。主要挑战之一在于神经网络常对分布外数据做出过度自信的预测。本研究提出一种有效的后处理方法,该方法的创新点包括全新的特征掩码策略和对数平滑策略。特征掩码策略依据分类器头中各类别的权重,为每个分布内类别确定倒数第二层的关键特征,并掩码其余特征。对数平滑策略通过计算测试样本特征向量与预测的分布内类别在倒数第二层的原型之间的余弦相似度,将该相似度作为自适应温度因子作用于对数输出,以缓解网络对分布外数据的过度自信预测。借助这些策略,我们能够降低分布外数据的特征激活程度,并扩大分布内数据与分布外数据在分布外评分上的差距。在多个标准分布外检测基准上的大量实验表明,我们的方法具有有效性及与现有方法的兼容性,并取得了新的最优性能。源代码将公开发布。