Out-of-distribution detection is a crucial technique for deploying machine learning models in the real world to handle the unseen scenarios.In this paper, we propose a simple but effective Neural Activation Prior (NAP) for out-of-distribution detection (OOD). Our neural activation prior is based on a key observation that, for a channel before the global pooling layer of a fully trained neural network, the probability of a few of its neurons being activated with a larger response by an in-distribution (ID) sample is significantly higher than that by an OOD sample. An intuitive explanation is each channel in a model fully trained on ID dataset would play a role in detecting a certain pattern in the samples within the ID dataset, and a few neurons can be activated with a large response when the pattern is detected in an input sample. Thus, a new scoring function based on this prior is proposed to highlight the role of these strongly activated neurons in OOD detection. This approach is plug-and-play and does not lead to any performance degradation on in-distribution data classification and requires no extra training or statistics from training or external datasets. Notice that previous methods primarily rely on post-global-pooling features of the neural networks, while the within-channel distribution information we leverage would be discarded by the global pooling operator. Consequently, our method is orthogonal to existing approaches and can be effectively combined with them in various applications. Experimental results show that our method achieves the state-of-the-art performance on CIFAR-10, CIFAR-100 and ImageNet datasets, which demonstrates the power of the proposed prior.
翻译:分布外检测是机器学习模型在现实世界中部署以应对未见场景的关键技术。本文提出一种简单而有效的神经激活先验(NAP)用于分布外检测(OOD)。该先验基于一个关键观察:对于全训练神经网络全局池化层前的某个通道,其部分神经元被分布内(ID)样本激活并产生较大响应的概率,显著高于被分布外样本激活的概率。直观解释是:在ID数据集上充分训练的模型中,每个通道负责检测ID样本中的特定模式,当输入样本检测到该模式时,部分神经元会产生强响应。基于此先验,我们提出新型评分函数以强化这些强激活神经元在OOD检测中的作用。该方法即插即用,不会导致分布内数据分类性能下降,且无需额外训练或从训练/外部数据集获取统计数据。值得注意的是,现有方法主要依赖神经网络全局池化后的特征,而我们所利用的通道内分布信息会被全局池化操作丢弃。因此本方法与现有方法正交,可在各类应用中有效结合。实验结果表明,本方法在CIFAR-10、CIFAR-100和ImageNet数据集上达到最优性能,充分验证了所提先验的有效性。