Towards Unknown-aware Learning with Virtual Outlier Synthesis

1 INTRODUCTION . Modern deep neural networks have achieved unprecedented success in known contexts for which they are trained , yet they often struggle to handle the unknowns . In particular , neural networks have been shown to produce high posterior probability for out-of-distribution ( OOD ) test inputs ( Nguyen et al. , 2015 ) , which arise from unknown categories and should not be predicted by the model . Taking self-driving car as an example , an object detection model trained to recognize in-distribution objects ( e.g. , cars , stop signs ) can produce a high-confidence prediction for an unseen object of a moose ; see Figure 1 ( a ) . Such a failure case raises concerns in model reliability , and worse , may lead to catastrophe when deployed in safety-critical applications . The vulnerability to OOD inputs arises due to the lack explicit knowledge of unknowns during training time . In particular , neural networks are typically optimized only on the in-distribution ( ID ) data . The resulting decision boundary , despite being useful on ID tasks such as classification , can be ill-fated for OOD detection . We illustrate this in Figure 1 . The ID data ( gray ) consists of three classconditional Gaussians , on which a three-way softmax classifier is trained . The resulting classifier is overconfident for regions far away from the ID data ( see the red shade in Figure 1 ( b ) ) , causing trouble for OOD detection . Ideally , a model should learn a more compact decision boundary that produces low uncertainty for the ID data , with high OOD uncertainty elsewhere ( e.g. , Figure 1 ( c ) ) . However , achieving this goal is non-trivial due to the lack of supervision signal of unknowns . This motivates the question : Can we synthesize virtual outliers for effective model regularization ? In this paper , we propose a novel unknown-aware learning framework dubbed VOS ( Virtual Outlier Synthesis ) , which optimizes the dual objectives of both ID task and OOD detection performance . In a nutshell , VOS consists of three components tackling challenges of outlier synthesis and effective model regularization with synthesized outliers . To synthesize the outliers , we estimate the class-conditional distribution in the feature space , and sample outliers from the low-likelihood region of ID classes ( Section 3.1 ) . Key to our method , we show that sampling in the feature space is more tractable than synthesizing images in the high-dimensional pixel space ( Lee et al. , 2018a ) . Alongside , we propose a novel unknown-aware training objective , which contrastively shapes the uncertainty surface between the ID data and synthesized outliers ( Section 3.2 ) . During training , VOS simultaneously performs the ID task ( e.g. , classification or object detection ) as well as the OOD uncertainty regularization . During inference time , the uncertainty estimation branch produces a larger probabilistic score for ID data and vice versa , which enables effective OOD detection ( Section 3.3 ) . VOS offers several compelling advantages compared to existing solutions . ( 1 ) VOS is a general learning framework that is effective for both object detection and image classification tasks , whereas previous methods were primarily driven by image classification . Image-level detection can be limiting as an image could be OOD in certain regions while being in-distribution elsewhere . Our work bridges a critical research gap since OOD detection for object detection is timely yet underexplored in literature . ( 2 ) VOS enables adaptive outlier synthesis , which can be flexibly and conveniently used for any ID data without manual data collection or cleaning . In contrast , previous methods using outlier exposure ( Hendrycks et al. , 2019 ) require an auxiliary image dataset that is sufficiently diverse , which can be arguably prohibitive to obtain . Moreover , one needs to perform careful data cleaning to ensure the auxiliary outlier dataset does not overlap with ID data . ( 3 ) VOS synthesizes outliers that can estimate a compact decision boundary between ID and OOD data . In contrast , existing solutions use outliers that are either too trivial to regularize the OOD estimator , or too hard to be separated from ID data , resulting in sub-optimal performance . Our key contributions and results are summarized as follows : • We propose a new framework VOS addressing a pressing issue—unknown-aware deep learning that optimizes for both ID and OOD performance . VOS establishes state-of-the-art results on a challenging object detection task . Compared to the best method , VOS reduces the FPR95 by up to 7.87 % while preserving the accuracy on the ID task . • We conduct extensive ablations and reveal important insights by contrasting different outlier synthesis approaches . We show that VOS is more advantageous than generating outliers directly in the high-dimensional pixel space ( e.g. , using GAN ( Lee et al. , 2018a ) ) or using noise as outliers . • We comprehensively evaluate our method on common OOD detection benchmarks , along with a more challenging yet underexplored task in the context of object detection . Our effort facilitates future research to evaluate OOD detection in a real-world setting . 2 PROBLEM SETUP . We start by formulating the problem of OOD detection in the setting of object detection . Our framework can be easily generalized to image classification when the bounding box is the entire image ( see Section 4.2 ) . Most previous formulations of OOD detection treat entire images as anomalies , which can lead to ambiguity shown in Figure 1 . In particular , natural images are composed of numerous objects and components . Knowing which regions of an image are anomalous could allow for safer handling of unfamiliar objects . This setting is more realistic in practice , yet also more challenging as it requires reasoning OOD uncertainty at the fine-grained object level . Specifically , we denote the input and label space by X = Rd and Y = { 1 , 2 , ... , K } , respectively . Let x ∈ X be the input image , b ∈ R4 be the bounding box coordinates associated with object instances in the image , and y ∈ Y be the semantic label for K-way classification . An object detection model is trained on in-distribution data D = { ( xi , bi , yi ) } Ni=1 drawn from an unknown joint distribution P . We use neural networks with parameters θ to model the bounding box regression pθ ( b|x ) and the classification pθ ( y|x , b ) . The OOD detection can be formulated as a binary classification problem , which distinguishes between the in- vs. out-of-distribution objects . Let PX denote the marginal probability distribution on X . Given a test input x∗ ∼ PX , as well as an object instance b∗ predicted by the object detector , the goal is to predict pθ ( g|x∗ , b∗ ) . We use g = 1 to indicate a detected object being in-distribution , and g = 0 being out-of-distribution , with semantics outside the support of Y . 3 METHOD . Our novel unknown-aware learning framework is illustrated in Figure 2 . Our framework encompasses three novel components and addresses the following questions : ( 1 ) how to synthesize the virtual outliers ( Section 3.1 ) , ( 2 ) how to leverage the synthesized outliers for effective model regularization ( Section 3.2 ) , and ( 3 ) how to perform OOD detection during inference time ( Section 3.3 ) ? 3.1 VOS : VIRTUAL OUTLIER SYNTHESIS . Our framework VOS generates virtual outliers for model regularization , without relying on external data . While a straightforward idea is to train generative models such as GANs ( Goodfellow et al. , 2014 ; Lee et al. , 2018a ) , synthesizing images in the high-dimensional pixel space can be difficult to optimize . Instead , our key idea is to synthesize virtual outliers in the feature space , which is more tractable given lower dimensionality . Moreover , our method is based on a discriminatively trained classifier in the object detector , which circumvents the difficult optimization process in training generative models . Specifically , we assume the feature representation of object instances forms a class-conditional multivariate Gaussian distribution ( see Figure 3 ) : pθ ( h ( x , b ) |y = k ) = N ( µk , Σ ) , where µk is the Gaussian mean of class k ∈ { 1 , 2 , .. , K } , Σ is the tied covariance matrix , and h ( x , b ) ∈ Rm is the latent representation of an object instance ( x , b ) . To extract the latent representation , we use the penultimate layer of the neural network . The dimensionality m is significantly smaller than the input dimension d. To estimate the parameters of the class-conditional Gaussian , we compute empirical class mean µ̂k and covariance Σ̂ of training samples { ( xi , bi , yi ) } Ni=1 : µ̂k = 1 Nk ∑ i : yi=k h ( xi , bi ) ( 1 ) Σ̂ = 1 N ∑ k ∑ i : yi=k ( h ( xi , bi ) − µ̂k ) ( h ( xi , bi ) − µ̂k ) > , ( 2 ) where Nk is the number of objects in class k , and N is the total number of objects . We use online estimation for efficient training , where we maintain a class-conditional queue with |Qk| object instances from each class . In each iteration , we enqueue the embeddings of objects to their corresponding class-conditional queues , and dequeue the same number of object embeddings . Sampling from the feature representation space . We propose sampling the virtual outliers from the feature representation space , using the multivariate distributions estimated above . Ideally , these virtual outliers should help estimate a more compact decision boundary between ID and OOD data . To achieve this , we propose sampling the virtual outliers Vk from the -likelihood region of the estimated class-conditional distribution : Vk = { vk| 1 ( 2π ) m/2|Σ̂|1/2 exp ( −1 2 ( vk − µ̂k ) > Σ̂−1 ( vk − µ̂k ) ) < } , ( 3 ) where vk ∼ N ( µ̂k , Σ̂ ) denotes the sampled virtual outliers for class k , which are in the sublevel set based on the likelihood . is sufficiently small so that the sampled outliers are near class boundary . Classification outputs for virtual outliers . For a given sampled virtual outlier v ∈ Rm , the output of the classification branch can be derived through a linear transformation : f ( v ; θ ) =W > clsv , ( 4 ) where Wcls ∈ Rm×K is the weight of the last fully connected layer . We proceed with describing how to regularize the output of virtual outliers for improved OOD detection . 3.2 UNKNOWN-AWARE TRAINING OBJECTIVE . We now introduce a new training objective for unknown-aware learning , leveraging the virtual outliers in Section 3.1 . The key idea is to perform visual recognition task while regularizing the model to produce a low OOD score for ID data , and a high OOD score for the synthesized outlier . Uncertainty regularization for classification . For simplicity , we first describe the regularization in the multi-class classification setting . The regularization loss should ideally optimize for the separability between the ID vs. OOD data under some function that captures the data density . However , directly estimating log p ( x ) can be computationally intractable as it requires sampling from the entire space X . We note that the log partition function E ( x ; θ ) : = − log ∑K k=1 e fk ( x ; θ ) is proportional to log p ( x ) with some unknown factor , which can be seen from the following : p ( y|x ) = p ( x , y ) p ( x ) = efy ( x ; θ ) ∑K k=1 e fk ( x ; θ ) , where fy ( x ; θ ) denotes the y-th element of logit output corresponding to the label y . The negative log partition function is also known as the free energy , which was shown to be an effective uncertainty measurement for OOD detection ( Liu et al. , 2020a ) . Our idea is to explicitly perform a level-set estimation based on the energy function ( threshold at 0 ) , where the ID data has negative energy values and the synthesized outlier has positive energy : Luncertainty = Ev∼V 1 { E ( v ; θ ) > 0 } + Ex∼D 1 { E ( x ; θ ) ≤ 0 } This is a simpler objective than estimating density . Since the 0/1 loss is intractable , we replace it with the binary sigmoid loss , a smooth approximation of the 0/1 loss , yielding the following : Luncertainty = Ev∼V [ − log 1 1 + exp−θu·E ( v ; θ ) ] + Ex∼D [ − log exp −θu·E ( x ; θ ) 1 + exp−θu·E ( x ; θ ) ] . ( 5 ) Here θu is a learnable parameter modulating the slope of the sigmoid function . The learning process shapes the uncertainty surface , which predicts high probability for ID data and low probability for virtual outliers v. Liu et al . ( 2020a ) employed energy for model uncertainty regularization , however , the loss function is based on the squared hinge loss and requires tuning two margin hyperparameters . In contrast , our uncertainty regularization loss is completely hyperparameter-free and is much easier to use in practice . Moreover , VOS produces probabilistic score for OOD detection , whereas Liu et al . ( 2020a ) relies on non-probabilistic energy score . Object-level energy score . In case of object detection , we can replace the image-level energy with object-level energy score . For ID object ( x , b ) , the energy is defined as : E ( x , b ; θ ) = − log K∑ k=1 wk · expfk ( ( x , b ) ; θ ) , ( 6 ) where fk ( ( x , b ) ; θ ) = W > clsh ( x , b ) is the logit output for class k in the classification branch . The energy score for the virtual outlier can be defined in a similar way as above . In particular , we will show in Section 4 that a learnable w is more flexible than a constant w , given the inherent class imbalance in object detection datasets . Additional analysis on wk is in Appendix H. Overall training objective . In the case of object detection , the overall training objective combines the standard object detection loss , along with a regularization loss in terms of uncertainty : min θ E ( x , b , y ) ∼D [ Lcls + Lloc ] + β · Luncertainty , ( 7 ) where β is the weight of the uncertainty regularization . Lcls and Lloc are losses for classification and bounding box regression , respectively . This can be simplified to classification task without Lloc . We provide ablation studies in Section 4.1 demonstrating the superiority of our loss function .

Summary: The manuscript addresses open-set object detection by modifying the ROI classifier of Faster-RCNN. The probability p(O|x,b) is modeled as sigmoidal activation of a generalized energy score of the classification head logits. The method succeeds if i) RPN ignores the outlier object, or ii) RPN detects the outlier but the candidate gets rejected due to high p(O|x,b).  The generalized energy is formulated as log-sum-weighted-exp-logit in equation (6). The probability p(outlier|x) is modeled as a sigmoid of modulated generalized energy in equations (8) and (9). The classification head is trained to output high energy in inliers and low energy in artificial outliers through equation (8). The artificial outliers are sampled from low-likelihood regions of per-class Gaussians which are fitted to latent features of groundtruth ROIs. These Gaussians are periodically updated during training.   It appears that the authors consider ROI-wide representations of RPN candidates. These representations are likely produced by applying ROI-align and two fully-connected layers to the convolutional features of the RPN. These Gaussian distributions are modelled according to per-class means (\mu_k) i and overall covariance (\Sigma). Virtual outliers are sampled so that their likelihood with respect to \mu_k and \Sigma is less than \epsilon.