A classifier trained on in-distribution (ID) data will, once deployed, also meet inputs from classes it never saw: out-of-distribution (OOD) data. OOD detection asks for a classifier that labels ID inputs correctly and flags OOD inputs, while training only on ID data. Many OOD detection algorithms are used in practice, but whether OOD detection admits a learning guarantee at all was posed as an open problem.
Fang, Li, Lu, Dong, Han and Liu (NeurIPS 2022) study this question in the style of agnostic PAC learning. They give a necessary condition for learnability (the linear condition), use it to prove impossibility theorems, and then identify spaces of distributions in which OOD detection is learnable. This mission formalizes the measure-theoretic core of Sections 2-5 of the paper.
Setting
The feature space is a set X⊆Rd and the ID labels are Y={1,…,K}; every OOD input carries the single label K+1. A domain is a mixture
DXY=(1−πout)DXIYI+πoutDXOYO,πout∈[0,1),
of an ID joint distribution and an OOD distribution. Training data are n i.i.d. samples from DXIYI only. For a loss ℓ with ℓ(y1,y2)=0 iff y1=y2 and a hypothesis h:X→Y∪{K+1}, the ID risk RDin(h), the OOD risk RDout(h) and the α-risk RDα=(1−α)RDin+αRDout are expectations of ℓ.
OOD detection is learnable in a set D of domains for a hypothesis space H if one algorithm A with values in H and one non-increasing sequence ϵ(n)→0 satisfy
ES∼DXIYInRD(A(S))≤h∈HinfRD(h)+ϵ(n)for every D∈D.
The paper considers priori-unknown spaces (closed under changing πout), the total space of all domains, the separate space Ds of domains whose ID and OOD supports are disjoint, and finite-ID-distribution spaces.
Formalization targets
Goal: impossibility theorem for the separate space (Theorem 5)
Suppose every point x∈X is classified as OOD by some h∈H (Assumption 1). Let ϕ map the ID labels to 1 and K+1 to 2. If VCdim(ϕ∘H)<∞ and suph∈H∣{x:h(x)∈Y}∣=∞, then OOD detection is not learnable in Ds for H. In contrast with supervised learning, a finite VC dimension does not give learnability, even with disjoint ID and OOD supports.
Milestones
Theorem 1: D′={DXYα} is priori-unknown and contains D. In a priori-unknown space learnability and strong learnability coincide, and strong learnability in D is equivalent to learnability in D′.
Lemma 1 (Condition 1 part): learnability in a priori-unknown space implies the linear condition infhRDα(h)=(1−α)infhRDin(h)+αinfhRDout(h).
Theorem 2: in the single-distribution space {DXYα:α∈[0,1)}, learnability is equivalent to the linear condition.
Theorem 3: if a domain of a priori-unknown space has overlapping ID and OOD distributions and both infimal risks vanish, the linear condition fails and OOD detection is not learnable.
Theorem 4: OOD detection is not learnable in the total space whenever ∣ϕ∘H∣>1.
Lemma 4: under Assumption 1, one finite discrete domain of Ds with infhRDout(h)>0 prevents learnability in Ds.
Theorem 6: for K=1 and finite X, under Assumption 1 and with the constant ID hypothesis in H, learnability in Ds holds if and only if H contains every hypothesis other than the constant OOD hypothesis.
Theorem 7: for finite X, Condition 2 and a binary part Hb containing every binary classifier other than the constant OOD one, OOD detection is learnable in Ds for Hin∙Hb.
Theorem 8 (sufficiency and rate, as proved): in a finite-ID-distribution space over a bounded X, the compatibility condition gives learnability with rate O(1/n1−θ) for every θ∈(0,1).
Significance
The results separate two questions that supervised learning theory merges: whether the hypothesis space is small (finite VC dimension) and whether the domain space allows the ID and OOD parts of the risk to be optimized at the same time (the linear and compatibility conditions). The impossibility theorems show that the second question decides learnability of OOD detection. The positive results describe settings, such as finite feature spaces and finitely many ID distributions, in which OOD detection is learnable.
Checking the statements formally showed that the necessity half of Theorem 8 is false as printed. The proof chooses a good training sample for each domain separately and then uses that sample for a whole class of domains. A counterexample with one ID distribution and countably many OOD point masses is recorded in the mission report. Only the sufficiency half of Theorem 8 is a target.
Difficulty
Theorem 1 and Lemma 1: limits of infima of α-risks as α→1, linearity of expectation, and measurability bookkeeping for [0,∞]-valued integrals.
Theorems 2-4: explicit constructions (constant algorithms, Dirac domains) and a Radon-Nikodym lower bound on the α-risk.
Lemma 4 and Theorem 5: a multi-linear version of the linear condition over point masses, and the Sauer-Shelah-Perles lemma to find a labelling that ϕ∘H cannot realize.
Theorems 6-8: explicit consistent algorithms (a nearest-sample rule on a finite feature space, and a test that identifies which of finitely many ID distributions generated the sample) together with their rates.
Formalization scope
Feature space: a subset X of Rd (EuclideanSpace ℝ (Fin d)) with the Borel σ-algebra and subspace topology. Hypotheses are measurable, which is the field's standing convention and is needed for the risks to be defined.
Domains: a domain is the triple (DXIYI,DXO,πout) of probability measures and a prior in [0,1). The paper's α-risks depend on DXO even when πout=0, so it is recorded separately.
Risks: risks take values in [0,∞] (they are finite because ℓ is bounded). Learnability requires the expected risk S↦RD(A(S)) to be almost-everywhere measurable, so that the expectation in Definition 1 is defined.
Labels:Y∪{K+1} is Fin (K+1) with K+1 the last element. The binary labels 1 (ID) and 2 (OOD) are 0 and 1 in Fin 2.
Implicit hypotheses made explicit:H=∅ in Theorems 2 and 8, and Hin=∅ in Theorem 7.
Not included:
The necessity half of Theorem 8 (learnability in DF implies Condition 3). It is false, and a counterexample is given in the report.
The Condition 4 (multi-linear condition) part of Lemma 1, and Lemma 3. The paper's Definition 6 of an OOD convex domain mixes OOD components with weights summing to 0, so it does not specify an OOD distribution at that point. The finite case needed for Theorem 5 is covered by Lemma 4.
Lemma 2, an equivalent reformulation of Condition 1 for a single domain that is used inside the proof of Theorem 2.
Lemma 5, which is Theorem 5 with an explicit size bound m>v in place of the infinite supremum.
Theorem 9 (density-based space, finite Natarajan dimension). Its proof relies on uniform-convergence bounds for an arbitrary class of measurable hypotheses with finite Natarajan dimension. Such bounds need measurability conditions that the paper does not state, and the constant Cθ is not derived.
Theorems 10-12 and Propositions 1-2, on hypothesis spaces generated by ReLU fully-connected networks and score functions. They are left out to keep the mission at ten statements. They would need definitions of network architectures and score-based classifiers, and Theorem 10 is an existence statement over architectures.
Lemmas 6-16, which are technical steps in the proofs of Theorems 6, 9 and 10-12.
Selected references
Z. Fang, Y. Li, J. Lu, J. Dong, B. Han and F. Liu, Is Out-of-Distribution Detection Learnable?, NeurIPS 2022, arXiv:2210.14707. https://arxiv.org/abs/2210.14707
J. Yang, K. Zhou, Y. Li and Z. Liu, Generalized Out-of-Distribution Detection: A Survey, arXiv:2110.11334, 2021. https://arxiv.org/abs/2110.11334
Goal · Theorem 5: impossibility theorem for the separate space
PROVED
namespace OODLearnable
theorem impossibility_separate_space {dim : ℕ} {𝒳 : Set (EuclideanSpace ℝ (Fin dim))} {K : ℕ}
(ℓ : Fin (K + 1) → Fin (K + 1) → ℝ≥0) (hℓ : IsOODLoss ℓ)
(H : Set (𝒳 → Fin (K + 1))) (hHmeas : ∀ h ∈ H, Measurable h) (hA1 : SeparateForOOD H)
(hVC : vcDim (phiComp H) < ⊤)
(hsup : (⨆ h ∈ H, {x | h x ≠ Fin.last K}.encard) = ⊤) :
¬ IsLearnable ℓ (separateSpace : Set (Domain 𝒳 K)) H := by sorry
end OODLearnable
Let X⊆Rd, let ℓ be a loss with ℓ(y1,y2)=0 iff y1=y2, and let H be a hypothesis space that is separate for OOD (Assumption 1). Let ϕ map the ID labels to 1 and the OOD label K+1 to 2. If
VCdim(ϕ∘H)<+∞andh∈Hsup{x∈X:h(x)∈Y}=+∞,
then OOD detection is not learnable in the separate space DXYs for H.
So, unlike supervised learning, a finite VC dimension does not guarantee learnability of OOD detection even when ID and OOD supports are disjoint.
Formalization Note Cardinalities and the supremum are taken in N∪{∞}. Supports in the definition of DXYs are topological supports in X. The feature space is X⊆Rd with the Borel structure; every hypothesis in H is assumed measurable (the paper's implicit convention, needed for the risks to be defined).
Frontier · Open leaf nodes
Recent activity
Frontier · Open leaf nodes
No open leaves. Every sub-goal is proved or awaiting decomposition.