Task-Driven Out-of-Distribution Detection with Statistical Guarantees for Robot Learning
Anonymous Author(s)
AfﬁliationAddress email
Abstract: Our goal is to perform out-of-distribution (OOD) detection , i.e., to detect when a robot is operating in environments that are drawn from a differentdistribution than the environments used to train the robot.
We leverage Probably Approximately Correct (PAC)-Bayes theory in order to train a policy with aguaranteed bound on performance on the training distribution.
Our key idea for
OOD detection then relies on the following intuition: violation of the performancebound on test environments provides evidence that the robot is operating OOD.
We formalize this via statistical techniques based on p-values and concentrationinequalities.
The resulting approach (i) provides guaranteed conﬁdence bounds on
OOD detection, and (ii) is task-driven and sensitive only to changes that impactthe robot’s performance.
We demonstrate our approach on a simulated exampleof grasping objects with unfamiliar poses or shapes.
We also present both simulation and hardware experiments for a drone performing vision-based obstacleavoidance in unfamiliar environments (including wind disturbances and differentobstacle densities).
Our examples demonstrate that we can perform task-driven
OOD detection within just a handful of trials.
Comparisons with baselines alsodemonstrate the advantages of our approach in terms of providing statistical guarantees and being insensitive to task-irrelevant distribution shifts.
Introduction
Imagine a drone trained to perform vision-based navigation using a dataset of indoor environmentsand deployed in environments with varying wind conditions, obstacle densities, or lighting (Fig. 1).
Similarly, consider a robot arm manipulating a new set of objects or an autonomous vehicle deployedin a new city.
State-of-the-art techniques for learning-based control of robots typically struggle togeneralize to such out-of-distribution (OOD) environments.
This lack of OOD generalization is particularly pressing in safety-critical settings, where the price of failure is high.
In this work, we focuson the problem of autonomously detecting when a robot is operating in environments drawn from adifferent distribution than the one used to train the robot.
This ability to perform OOD detection hasthe potential to improve the safety of robotic systems operating in OOD environments.
For example,a drone operating in a new set of environments could either deploy a highly conservative policy orcease its operations altogether.
In addition, OOD detection can also allow the robot to improve itspolicy by re-training using additional data collected from the new environments.
There are two important desiderata that OOD detection approaches for safety-critical robotic systems should ideally satisfy.
First, we would like to develop OOD detection techniques with guaranteed conﬁdence bounds .
Second, we would like our OOD detectors to be task-driven and onlysensitive to task-relevant changes in the robot’s environment.
As an example, consider again thedrone navigation setting in Fig.
1 and suppose that the robot’s policy is insensitive to changes incolor and lighting.
Here, the robot’s OOD detector should not trigger even if the robot is operatingin environments with different color/lighting and should only trigger if there are task-relevant variations (e.g., variations in the obstacle density).
Unfortunately, current approaches (Sec. 2) do nottypically satisfy both desiderata; they are often based on heuristics and not task-driven in general.
Statement of Contributions.
We develop task-driven OOD detection techniques with statistical guarantees on correctness.
To this end, we make three speciﬁc contributions (see Fig.
1 for an overview).
• Given a dataset of environments drawn from an (unknown) training distribution, we develop a
pipeline based on generalization theory for training control policies with a guaranteed boundon performance (a bound on the expected cost of the policy on the unknown training distribution).
Speciﬁcally, we leverage recently-developed derandomized Probably Approximately Cor- rect (PAC)-Bayes bounds that are well-suited to enable OOD detection (Sec.
4.1).• We develop two OOD detection techniques with complementary statistical interpretations based on the following intuition (Sec. 4.2): if the costs incurred when the robot is deployed in new environments violate the bound on the policy’s performance, then this indicates that the robot isoperating OOD.
We formalize this via p-values and concentration inequalities and provide statis- tical guarantees on the false positive rate of OOD detection.
Since our OOD detection scheme leverages the costs incurred in new environments, it is only triggered by task-relevant changes.
• We demonstrate our approach on two simulated examples (Sec. 5):
(i) a robotic manipulator grasping a new set of objects, and (ii) a drone navigating a new set of environments.
Comparisons withbaselines demonstrate the advantages of our approach in terms of providing statistical guarantees
and being insensitive to task-irrelevant shifts.
We also present a thorough set of hardware exper- iments for vision-based drone navigation with varying wind conditions and clutter (Fig. 1).
Our
experiments demonstrate the ability of our approach to perform task-driven OOD detection within
just a handful of trials for systems with complex dynamics and rich sensing modalities
Related work
Anomaly/OOD detection in supervised learning.
Anomaly detection in low-dimensional signalshas been well-studied in the signal processing literature (see [1] for a review).
Recent work inmachine learning has focused on OOD detection for high-dimensional inputs (e.g., images) in supervised learning settings (see [2] for a review).
Popular approaches use threshold-based detectorsfor the output distribution of a given pre-trained neural classiﬁer [3, 4, 5].
Other methods use aspeciﬁc pipeline for training a neural network in order to improve OOD detection on test samples[6, 7, 8].
However, these methods are often susceptible to adversarial attacks [9].
Thus, approachesfor addressing adversarial data have been developed [10, 9, 11].
Some of these approaches are alsoable to provide theoretical guarantees of performance on adversarial data [9, 12, 13].
Other methodsprovide PAC-style statistical guarantees [14, 15] or p-values [16].
However, these methods typicallyfocus on supervised learning settings and often require speciﬁc network outputs (e.g., softmax) thatare incompatible with non-classiﬁcation tasks.
In contrast, we focus on OOD detection for policylearning settings in robotics and do not make assumptions about the speciﬁc structure of the policy.
Task-driven OOD detection.
The methods above are aimed at detecting any distributional shift inthe data and can be sensitive even to task- irrelevant shifts (i.e., ones that do not impact performance)as we demonstrate in our experiments (Sec. 5).
A recent approach determines an estimate of input atypicality for pre-trained networks and uses it as an OOD detector in supervised learning settings[17].
Recent methods have also been developed speciﬁcally for reinforcement learning (RL) [18,19, 20, 21, 22].
In particular, [22] presents a general task-driven approach for OOD detection onsequential rewards, which is optimal in certain settings.
However, neither this method nor others inthe RL context provide statistical guarantees on detection.
We propose an OOD detection frameworkwhich is both task-driven and provides statistical guarantees by leveraging generalization theory.
Generalization theory.
Generalization theory provides a way to learn hypotheses (in supervisedlearning) with a bound on the true expected loss on the underlying data-generating distributiongiven only a ﬁnite number of training examples.
Original frameworks include Vapnik-Chervonenkis(VC) theory [23] and Rademacher complexity [24].
However, these methods often provide vacuous generalization bounds for high-dimensional hypothesis spaces (e.g., neural networks).
Boundsbased on PAC-Bayes generalization theory [25, 26, 27] have recently been shown to provide strongguarantees in a variety of settings [28, 29, 30, 31, 32, 33], and have been signiﬁcantly extended andimproved [34, 35, 36, 37, 38, 39].
PAC-Bayes has also recently been extended to learn policies forrobots with guarantees on generalization to novel environments [40, 41, 42, 43].
In the present work,we leverage recently-proposed derandomized PAC-Bayes bounds [44]; this framework allows us totrain a single deterministic policy with a guaranteed bound on expected performance on the trainingdistribution (in contrast to [40, 41, 42, 43], which train stochastic neural network policies).
Thisforms the basis for our OOD detection framework: by observing violations of the PAC-Bayes boundon test environments, we are able to perform task-driven OOD detection with statistical guarantees.
Problem formulation
Dynamics and environments.
Let s t +1 =
f E ( s t , a t ) describe the robot’s dynamics, wheres t 2 S ✓ R n s is the state of the robot at time-step t , a t 2 A ✓ R n a is the action, and E 2 E is the 101 environment that the robot is operating in.
“Environment” here broadly refers to factors that are external to the robot, e.g., a cluttered room that a drone is navigating, disturbances such as wind gusts,or an object that a manipulator is grasping.
The dynamics of the robot may be nonlinear/hybrid.
Wedenote the robot’s sensor observations (e.g., RGB-D images) by o t 2 O ✓ R n o .
Cost functions.
The robot’s task is encoded via a cost function and we let C E ( ⇡ ) denote the costincurred by a (deterministic) policy ⇡ when deployed in environment E over a ﬁnite time horizon T .
The policy ⇡ 2 ⇧ is a mapping from (histories of) sensor observations to actions (e.g., parameterizedusing a neural network).
In the context of obstacle avoidance, the cost could capture how close thedrone gets to an obstacle; in the context of grasping, the cost could be 0 if the robot successfully liftsthe object or 1 otherwise.
We assume that the cost is bounded; without further loss of generality, weassume C E ( ⇡ ) 2 [0 , 1] .
We also assume that the robot has access to the cost C E ( ⇡ ) after performinga rollout on E (i.e., at the end of an episode of length T ).
This is a relatively benign assumptionin robotics contexts since the cost function often has physical meaning and can be measured bythe robot’s sensors.
For example, a drone equipped with a depth sensor can measure the smallestreported depth value during its operation in an environment, and a manipulator equipped with acamera and/or force-torque sensor can measure if it successfully grasped an object.
We make nofurther assumptions on the cost function (e.g., we do not assume continuity, Lipschitzness, etc.).
Training and testing distribution.
We assume that the robot has access to a training dataset S ={ E 1 , . . .
, E m } of m environments drawn i.i.d.
from a training distribution D , i.e. S ⇠ D m .
Aftertraining, the robot is deployed on environments in S
= { E 0 1 , . . .
, E 0 n } drawn from a test distribution
D 0 : S
⇠ D 0 n .
Importantly, we do not assume any explicit knowledge of D , D 0 or the space E of 122 environments. We only have indirect access to D , D 0 in the form of the ﬁnite training datasets S, S 0 .
Goal: task-driven OOD detection.
After being deployed in (a typically small number of) environments in S 0 , the robot’s goal is to detect if these environments were drawn from a differentdistribution than the training distribution (i.e., if D 0 is different from D ).
Moreover, our goal is toperform task-driven OOD detection.
In particular, our OOD detector should only trigger if:
[Equation]
Thus, our OOD detector should be insensitive to changes in the environment distribution that donot adversely 1 impact the robot’s performance.
This is a challenging task since we only assume access to a ﬁnite number of environments from D and D 0 .
Moreover, our goal is to develop an OODdetection framework that is broadly applicable in challenging settings involving nonlinear/hybriddynamics, rich sensing modalities (e.g., RGB-D), and neural network-based policies.
Approach
Our overall approach is illustrated in Fig.
First, we train a policy with an associated guaranteeon the expected cost on the training distribution D (Sec. 4.1).
We then apply our OOD detectionscheme which formalizes the following intuition: violation of the bound during deployment implies(with high conﬁdence) that the test distribution D 0 is OOD in a task-relevant manner (Sec. 4.2).
4.1 Policy training via derandomized PAC-Bayes bounds
Given a training dataset S = { E 1 , . . .
, E m } of m environments drawn i.i.d.
from the training distribution D , our goal is to learn a policy ⇡ with a guaranteed bound on the expected cost
C D ( ⇡ ) := E E ⇠ D C E ( ⇡ ) .
Since our OOD detection scheme will rely on violations of the bound, itis important to obtain bounds that are as tight as possible.
In this work, we utilize the Probably Approximately Correct (PAC)-Bayes framework [25, 26, 27] to train policies with strong guarantees.
More speciﬁcally, we leverage recently-developed derandomized PAC-Bayes bounds [44], whichare well-suited to the OOD detection setting (as we explain further below).
PAC-Bayes applies to settings where one chooses a distribution over policies (e.g., a distribution overweights of a neural network), and learning algorithms that have the following structure: (1) choose a“prior” distribution P 0 over the policy space ⇧ before observing any data (this can be used to encodedomain/expert knowledge); (2) obtain a training dataset S and choose a posterior distribution P overthe policy space ⇧ .
Let P be the output of an algorithm A which takes P 0 and S as input.
Denote thecost incurred by a policy ⇡ on the training environments in S as C S ( ⇡ ) :
= 1 m
P
E 2 S C E ( ⇡ ) .
The
Theorem 1 For any distribution D , prior distribution P 0 ,  2 (0 , 1) , cost bounded in [0 , 1] , m  8 ,and deterministic algorithm A which outputs the posterior distribution P , we have the following:
[Equation]
where C  ( ⇡ , S ) :
= C S [Equation] + [Equation]
[Equation] = [Equation] ln
[Equation]
m [Equation] [Equation] 2 m ) , and D 2 is the R´enyi
Divergence for ↵ = 2 deﬁned as: D [Equation]
Proof.
The proof is in App.
A.1.
We use [44, Theorem 2], a general pointwise PAC-Bayes bound.
We perform the reduction from supervised learning to policy learning presented in [40].
This result allows us to obtain policies with guaranteed bounds on the expected cost.
In particular, wecan search for a posterior P in order to minimize the sum of the training cost and the “regularizer”p R .
We describe such training methods via backpropagation and blackbox optimization below.
Sampling from the resulting posterior P provides a policy with a bound on C D ( ⇡ ) that holds withhigh probability (over the sampling of the training dataset S and the policy ⇡ ).
Recent work has demonstrated the effectiveness of PAC-Bayes to provide strong bounds for deepneural networks [28, 31, 33] and speciﬁcally for policy learning [40, 41, 42, 43].
However, thebounds used by these approaches do not provide a viable approach for performing OOD detection.
The approaches are based on traditional PAC-Bayes bounds, where a distribution P over policies(e.g.
, a distribution over neural network weights) is chosen; the resulting bound is on E ⇡ ⇠ P C D ( ⇡ )instead of C D ( ⇡ ) .
Thus, given a test dataset S 0 of environments, many policies from the distribution P must be sampled in order to evaluate/bound the expected cost on S 0 .
This is not feasible in an
OOD detection setting, where there is single execution on the test environments.
Our use of thederandomized PAC-Bayes bound in Theorem 1 avoids this issue since we can bound C D ( ⇡ ) for aparticular policy sampled from P .
We provide approaches for optimizing the bound provided in Theorem 1 using backpropagation(App.
A.4) and Evolutionary Strategies (ES) [45] (App. A.5). Since Theorem 1 requires a deterministic training algorithm, we ﬁx the random seed for stochastic training methods. This makes thealgorithm deterministic as the same input will always produce the same output.
We choose multivariate Guassian distributions with diagonal covariance diag ( s ) , i.e., P = N ( µ, diag ( s )) , for the posterior P and prior P 0 distributions.
Further, let :=
( µ, log s ) ; we use the shorthand N for N ( µ, diag ( s )) .
We denote ⇡ w with weights w ⇠ N as a parameterization of the robot’s policy (e.g.,neural networks with weights w ).
After training, we sample and ﬁx a w from the trained posteriorfor deployment on test environments.
We then compute the PAC-Bayes upper bound C  ( ⇡ , S ) .
4.2 Task-driven OOD detection with statistical guarantees
We now tackle the problem of OOD detection as deﬁned in Sec. 3.
The PAC-Bayes training pipelinefrom Sec.
4.1 produces a policy ⇡ and an associated bound C  ( ⇡ , S ) on the expected cost C D ( ⇡ )that holds with probability 1   over the sampling of the training dataset S
⇠ D m and the policy⇡ ⇠ P .
Our key idea for OOD detection is that if our PAC bound C  ( ⇡ , S ) is violated by ⇡ in the testenvironments S 0 (drawn from the test distribution D 0 ), then this indicates that the test environmentsare OOD.
We formalize this intuition below using two popular frequentist statistical inference tools— hypothesis testing via p-value and conﬁdence interval overlap.
Method 1: Hypothesis testing
In accordance with our notion of task-driven OOD detection (1) described in Sec. 3, let H 0 be thenull-hypothesis which claims that C D 0 ( ⇡ )  C D ( ⇡ ) and let H 1 be the alternate hypothesis whichclaims that C D 0 ( ⇡ )
>
C D ( ⇡ ) for a given policy ⇡ .
Then, to perform a hypothesis test, we computethe p-value and check if it drops below a signiﬁcance level ↵ 2 (0 , 1) , which is chosen beforelooking at the data.
The p-value bounds the probability of drawing test environments with averagecost larger than the observed test cost C S 0 ( ⇡ ) , assuming that the null-hypothesis holds.
In the eventthat the p-value is smaller than ↵ , we can conclude that under the null-hypothesis the observed testdataset S 0 had a very small probability of being drawn; therefore, the null-hypothesis H 0 can berejected.
A mathematically precise deﬁnition of the p-value is given as follows.
Deﬁnition 1 (adapted from [46]) Let D 0 be the test distribution and S
⇠ D 0 n be an observed 201 dataset.
Let ⇡ be the robot’s control policy.
Then, the p-value is deﬁned as:
[Equation]
Note that ˆ S is any dataset of cardinality n drawn i.i.d.
from the test distribution D 0 n , while S 0is the observed test dataset which we must use for inference.
We present an upper bound on thep-value by leveraging the PAC-Bayes generalization bound (Theorem 1).
This upper bound holdswith probability 1   (over the sampling of S and ⇡ ).
Theorem 2 Let D be the training distribution and P be the posterior distribution on the space ofpolicies obtained through the training procedure described in Sec. 4.1.
Let S
⇠ D 0 n be a testdataset, p ( S 0 ) be the p-value for S 0 deﬁned in Deﬁnition 1, and  2 (0 , 1) .
Then,
[Equation]
where ⌧ ( S ) :
= max { C S 0 ( ⇡ )  C  ( ⇡ , S ) , 0 } .
Proof.
The proof relies on Hoeffding’s inequality and is provided in App.
A.2.
Theorem 2 provides an upper bound on the p-value which holds with high conﬁdence.
If the upperbound is below the signiﬁcance level ↵ , then with high conﬁdence we can say that the p-value isbelow ↵ ; thereby, Theorem 2 facilitates OOD detection through hypothesis testing.
Method 2: Conﬁdence interval on the difference in expected train and test costs
We now present another method for performing task-driven OOD detection (Sec. 3 and Eq.
(1)) bylower bounding C D 0 ( ⇡ )  C D ( ⇡ ) with high probability.
If the lower bound is positive, then withhigh conﬁdence we can conclude that the robot is operating in (task-relevant)
OOD environments asthe test cost is larger than the train cost.
Furthermore, this lower bound serves as a measure of how“far” the two distributions are from the perspective of the task.
Theorem 3 Let D be the training distribution, D 0 be the test distribution, and P be the posteriordistribution on the space of policies obtained through the training procedure described in Sec. 4.1.
Let  ,  0 2 (0 , 1) such that  +  0 < 1 ,  := q [Equation] [Equation]
[Equation]
2 n , and  C := C S 0 ( ⇡ )    C  ( ⇡ , S ) .
Then,
[Equation]
Proof.
A detailed proof of this theorem is provided in App. A.3.
To use Theorem 3 for detecting if a test dataset S 0 is OOD, we ﬁrst choose  and  0 to obtain adesired conﬁdence level 1     0 for our OOD detector.
Using these constants and the policy ⇡drawn from P trained using the PAC-Bayes upper bound, we then compute  C .
If  C > 0 , thenwith conﬁdence at least 1     0 we can claim that C D 0 > C D , and therefore, with the same 228 level of conﬁdence the test dataset S 0 must be OOD according to our task-relevant notion in (1).
Furthermore, we obtain a guaranteed upper bound of  +  0 on the false positive rate of our OODdetector, i.e., the rate at which our detector will misclassify training distribution data as OOD.
Examples
We demonstrate the ability of our approach to perform task-driven OOD detection with guaranteedconﬁdence bounds on two simulated examples: a manipulator grasping a new set of objects and adrone navigating a new set of environments.
For the navigation task, we compare our methods withpopular OOD detection baselines.
Our code is provided in the supplementary material.
5.1 Robotic grasping
Overview.
We use the Franka Panda arm (Fig. 2(a)) for grasping objects in the PyBullet simulator[47] and build upon the open-source code provided in [42].
The robot employs a vision-based controlpolicy that uses a depth map of the object obtained from an overhead camera and returns an openloop action a :=
( x, y, z, ✓ ) which corresponds to the desired grasp position and yaw orientation ofthe gripper.
We train the manipulator to grasp mugs placed in SE (2) poses drawn from a speciﬁcdistribution.
Then, we demonstrate the efﬁcacy of our OOD detection framework by (i) graduallymodifying the distribution on the mug poses and (ii) changing the objects from mugs to bowls.
Control policy.
The control policy is a deep neural network (DNN) which inputs a 128 ⇥ 128 depthmap of the object and a latent state z 2 R 10 sampled from a multivariate Gaussian distribution Nwith a diagonal covariance, and outputs an open-loop grasp action a ; see Fig.
A.1 in App.
A.6.1 forthe policy.
In [42], the distribution N on the latent space encodes prior domain/expert knowledge.
Training.
Mugs from the ShapeNet dataset [48] are randomly scaled in all dimensions to generatea training dataset S of 500 mugs.
If the robot is able to lift the mug by 10 cm and the gripper palmdoes not contact it, then we consider the rollout successful and assign a cost of 0; otherwise the costis set to 1.
In training, we optimize the distribution N on the latent space to minimize the PACBayes upper bound provided in Theorem 1 using Alg.
A.2, while the weights of the CNN and MLPnetworks in Fig.
A.1 in App.
A.6.1 remain ﬁxed.
The prior N 0 is chosen as the normal distributionwith zero mean and identity covariance.
A policy ⇡ is sampled from the trained posterior N andthe PAC-Bayes bound for this policy is computed as C  ( ⇡ , S )
= 0 .
1 with  = 0 .
OOD detection results.
We perform OOD detection using the two methods presented in Theorem 2and Theorem 3.
For detection with p-value, we choose a signiﬁcance level ↵ = 95% , while, fordetection using  C
we choose a conﬁdence level of 95% , i.e.,  +  0 = 0 .
05 , which ensures that thefalse-positive rate of our detector is no greater than 5% .
We perform two experiments to demonstratethe efﬁcacy of our approach for OOD detection.
First, we make the distribution on the mug’s initialplacement progressively more challenging; see App.
A.6.1 for the exact distributions.
For eachdistribution, we sample 20 test datasets of cardinality 10 and compute our OOD indicators: (i) thelower bound on 1  p (where p is the p-value) and (ii)  C using Theorem 3.
Fig.
2(b) plots themean (dashed line) and a one standard deviation spread (shaded region) for the OOD indicators asa function of C D 0  C D (estimated via exhaustive sampling).
Note that we plot  C + 0 .
so thatthe OOD threshold is the same (0.95) for both methods.
As the cost of the policy deteriorates on testdistributions our OOD indicators reliably increase, capturing the shift of the test distributions awayfrom the training distribution.
In the second experiment, we change the objects that the manipulatormust grasp from mugs to bowls.
Fig. 2(c) shows that with a small test dataset S 0 of cardinality 5,both our approaches detect OOD when bowls are used (red curves).
As expected, our OOD detectorsare not triggered for mugs (blue curves), which are drawn from the training distribution.
5.2 Vision-based obstacle avoidance with a drone
Overview.
In both the simulation and hardware portions of this example, we aim to avoid an obstacleﬁeld with the Parrot Swing drone; this is an agile quadrotor/ﬁxed-wing hybrid drone shown in Fig. 1.
We train a DNN control policy in a simulation setup based on the hardware system shown in Fig.
[Figure]
The policy takes in a 50 ⇥ 50 depth image and outputs a softmax corresponding to a set of precomputed motion primitives with the goal of avoiding obstacles by the largest distance.
Since wedesigned the simulation portion of this example with application to hardware in mind, we havecreated motion primitives by capturing (with a Vicon motion tracking system) the trajectories ofopen-loop control inputs, which result in different maneuvers; the two images in Fig.
1 representtwo of these trajectories.
The use of motion primitives allows us to perform accurate sim-to-realtransfer (since the motion primitives are recorded directly from the hardware system).
Training.
Environments consist of a set of randomly placed cylindrical obstacles.
We record theminimum distance d min from the obstacles (as recorded by the robot’s 120  ﬁeld of view depthsensor) and assign a cost of max(0 , 1  d min 30cm ) .
Using 10 , 000 training environments S , we train aprior to assign larger values to motion primitives which achieve a larger distance from obstacles.
See
App. A.6.2 for further details on the training procedure for the prior.
We then use another 10 , 000environments to train the posterior distribution using Alg. A.1.
We sample a policy ⇡ from thetrained posterior and compute the PAC-Bayes bound C  ( ⇡ , S )
= 0 .
222 for  = 0 .
Simulation Results
We compare our task-driven OOD detection approach with two baselines: (i) maximum softmaxprobability (MSP) [3] (an effective and popular baseline for OOD detection), and (ii) MaxLogit[5] (a recent state-of-the-art OOD detection baseline).
We note that these baselines are speciﬁcallydesigned for networks which output categorical distributions, and thus provide strong benchmarks.
We determine the threshold for detection for the baselines by choosing a false positive rate of 5%for the training environments.
However, note that the baselines do not provide any guarantees; theymay violate the false positive rate even on new environments drawn from the training distribution (aswe observe in our experiments).
We select a p-value of 0 .
as the indication that an environment is
OOD, and a guaranteed false-positive rate of  +  0 = 5% for the conﬁdence interval method.
Eachmethod receives a dataset S 0 of 10 environments.
We use the average outputs of the baselines onthe 10 environments for OOD detection.
We generate OOD environments of varying difﬁculty bychanging the number of obstacles and the maximum or minimum gap-size between obstacles.
Varied environment difﬁculty.
We sample 2000 datasets S 0 (of size 10) for each setting and plotthe proportion of these detected as OOD for all methods in Fig. 3(a).
At 0 on the x-axis of this plot,we draw datasets from the training distribution.
All other environments are OOD.
We note that thep-value and conﬁdence interval-based methods perform similarly.
The plot demonstrates our abilityto perform task-driven OOD detection.
In particular, we only detect the “harder” distributions (i.e.,environments with higher increased cost) as OOD, while the baselines are triggered even for theeasier distributions.
In addition, neither baseline provides any guarantees and both violate the 5%false-positive rate on the training distribution.
Our methods have a low false positive rate, albeit atthe cost of conservatism for moderate distribution shifts.
Task-irrelevant shift.
We also compare the baselines with our methods on a distribution whereenvironments consist of 4 (uniformly) randomly located obstacles.
In this setting, the control policyachieves a near-identical expected cost C D 0 ( ⇡ ) (as estimated by exhaustive sampling of environments) to the expected training cost C D ( ⇡ ) (in particular, C D 0 ( ⇡ ) - C D ( ⇡ ) =
0 . 02 ).
For thissetting, MSP [3] classiﬁed 95 .
7% of test datasets as OOD and MaxLogit [5] classiﬁed 50 .
9% as
[Figure]
OOD.
Thus, the baselines are triggered by a task-irrelevant shift in the distribution.
In contrast, ourmethods had an OOD detection rate of 0 .
1% in this setting.
[Figure]
Hardware Results
[Figure] We use a Parrot Swing drone for the hardware experiments (Fig. 1).
We simulate a depth sensorfor the drone (as if the sensor was mounted on the drone) by generating a synthetic depth imageusing the positions of objects from the Vicon motion capture system.
We do not provide any otherinformation to the policy (e.g., obstacle positions).
We generate each environment the same way asin simulation, and then place the real-world obstacles in the generated locations.
Varied environment difﬁculty and wind disturbances.
We deploy the policy trained in simulationon three kinds of OOD environments in hardware: (i) environments with a smaller number of obstacles (“easier” environments), (ii) environments with smaller gaps between obstacles (i.e., “harder”environments), and (iii) environments with wind generated using a fan (Fig. 1 right) with the sameobstacle distribution as training.
Videos from each setting are provided in the supplementary materials.
For each setting, we run 10 trials on the hardware and use this for OOD detection.
As expected,our OOD detectors are not triggered by the easier environments.
For the harder environments, wecompute 1  p  0 .
81 and  C =  0 .
Results from the windy environments are shown in Fig. 3(b) for increasing values of wind (up to about 5 m / s ).
We note that the sim-to-real distributionshift (corresponding to the zero wind case) is not viewed as being OOD in a task-relevant mannerby our approaches.
Both our approaches assign increasingly high conﬁdence as the wind speed isincreased.
We note that disturbances such as wind cannot be detected via the depth image givento the robot’s policy.
Thus any OOD detection technique which relies solely on the output of thepolicy, such as MSP [3] and MaxLogit [5], would be unable to detect these environments as OOD.
Conclusion
We have presented a framework for performing task-driven OOD detection with statistical guarantees.
Our approach uses PAC-Bayes theory to train a policy with a bound on the expected cost onthe training distribution.
We then perform OOD detection on test environments by checking for violations of the bound (using p-values and concentration inequalities).
Our simulated and hardwareexperiments demonstrate the ability of our approach to perform OOD detection within a handful oftrials.
Comparisons with baselines also demonstrate two advantages: our OOD detectors (i) are onlysensitive to task-relevant distribution shifts, and (ii) provide statistical guarantees on detection.
Challenges and future work.
The approach we present here allows us to bound the false positiverate.
An interesting theoretical question is whether we can also bound the false negative rate.
Itwould also be of practical interest to extend our approach to settings where the robot encountersenvironments in an online manner (instead of the batch setting we consider here).
Another particularly exciting direction is to develop versions of our approach that are more proactive ; instead ofhaving to incur costs on the test environments, one could potentially perform OOD detection basedon predicted costs (thus avoiding the need to potentially fail on the test environments).