Learning Bounds for Open-Set Learning
Zhen Fang, Jie Lu, Anjin Liu, Feng Liu, Guangquan Zhang
Introduction
Supervised learning has achieved dramatic successes in many applications such as object detection (Simonyan & Zisserman, 2015), speech recognition (Graves & Jaitly, 2014) and natural language processing (Collobert & Weston, 2008). These successes are partly rooted in the closed-set assumption that training and test samples share a same label space. Under this assumption, the standard supervised learning is also regarded as closed-set learning (CSL) (Geng et al., 2018; Yang et al., 2020).
However, the closed-set assumption is not realistic during the testing phase (i.e., there are no labels in the samples) since it is not known whether the classes of test samples are from the label space of training samples. Test samples may come from some classes (unknown classes) that are not necessarily seen during training. These unknown classes can emerge unexpectedly and drastically weaken the performance of existing closed-set algorithms (de O. Cardoso et al., 2017; Dhamija et al., 2018; Perera et al., 2020).
To solve supervised learning without closed-set assumption, Scheirer et al. (2013) proposed a new problem setting, open-set learning (OSL), in which the test samples can come from any classes, even unknown classes. An open-set classifier should classify samples from known classes into correct known classes while recognizing samples from unknown classes into unknown classes.
Remarkable advances have been achieved in open-set learning. The key challenge of OSL algorithms is to recognize the unknown classes accurately. To address this challenge, different strategies have been proposed such as open-space risk (Scheirer et al., 2013) and extreme value theory (Jain et al., 2014; Rudd et al., 2018). Further, to adapt deep networks support to OSL, Bendale & Boult (2016), Ge et al. (2017) proposed OpenMax and G-OpenMax, respectively.
While many OSL algorithms can be roughly interpreted as minimizing the open-space risk or using the extreme value theory, several disconnections still form non-negligible gaps between the theories and algorithms (Geng et al., 2018; Boult et al., 2019). Very little theoretical groundwork has been undertaken to reveal the generalization ability of OSL from the perspective of learning theory.
This work aims to bridge the gap between the theory and algorithm for OSL from the perspective of learning theory. In particular, our theory answers an important question: under some assumptions, given training samples with size , then there exists an OSL algorithm such that the estimation error is close to . This result reveals OSL problem can achieve an order of estimation error that is the same as CSL (Shalev-Shwartz & Ben-David, 2014).
Since the test samples contain unknown classes, the distribution of test samples is intrinsically different from that of training samples. Based on this fact, we aim to establish the OSL theory from transfer learning (Luo et al., 2020a; Niu et al., 2020; Dong et al., 2020b; Lu et al., 2015; Dong et al., 2019, 2020a; Pan & Yang, 2010; Dong et al., 2021; Liu et al., 2019; Wang et al., 2020), which learns knowledge for a given domain from a different, but relative domain. Using the transfer learning theory, we focus on constructing a suitable auxiliary domain, which contains the information of unknown classes. The construction of auxiliary domain depends on covariate shift (Santurkar et al., 2018). Transferring information from the auxiliary domain, we construct the generalization bound for OSL by using the transfer learning bound developed by Ben-David et al. (2006), Mansour et al. (2009), Fang et al. (2020b), Zhong et al. (2020; 2021), Luo et al. (2020b).
Guided by our theory, we then devise an algorithm for OSL to bring the proposed OSL theory into reality. The novel algorithm auxiliary open-set risk (AOSR) is a neural network-based algorithm. AOSR mainly utilizes the instance-weighting strategy to align training samples and auxiliary samples generated by an auxiliary domain. Then, minimizing the auxiliary risk developed by our theory, AOSR can learn how to recognize unknown classes.
The contributions of this paper are summarized as follows.
We provide the theoretical analysis for open-set learning based on transfer learning and PAC theory. This is the first work to investigate the generalization error bound for open-set learning.
Our theory answers an important question: under some assumptions, there exists an OSL algorithm such that the order of the estimation error is close to , if given training samples with size .
We conduct experiments on toy and benchmark datasets. Experiments support our theoretical results and show that our theoretical guided algorithm AOSR can achieve competitive performance compared with several popular baselines.
Related Works
Open-Set Learning Theory. One of the pioneering theoretical works in this field was conducted by Scheirer et al. (2013; 2014). They proposed the open-space risk, which means that when a sample is far from the training samples, there is an increased risk that the sample is from unknown classes. By minimizing the open-space risk, samples from unknown classes can be recognized. Jain et al. (2014), Rudd et al. (2018) consider the extreme value theory to solve the OSL problem. Extreme value theory is a branch of statistics analyzing the distribution of samples of abnormally high or low values. Liu et al. (2018) first proposed the PAC guarantees for open-set detection. Unfortunately, the test samples are required to be used in the training phase. Fang et al. (2020b) considered the open-set domain adaptation (OSDA) problem (Luo et al., 2020b; Busto et al., 2020) and proposed the first estimation for the generalization error of OSDA by constructing a special term, open-set difference. However, similar to Liu et al. (2018), test samples are needed during the training phase.
Open-Set Algorithm. We can roughly separate OSL algorithms into two different categories: shadow algorithms (e.g., support vector machine (SVM)) and deep learning-based algorithms. In shadow algorithms, Scheirer et al. (2013; 2014) proposed the OSL algorithms based on SVM. Jain et al. (2014), Rudd et al. (2018) proposed OSL algorithms based on extreme value theory. Recently, deep-based algorithms have been developed dramatically. OpenMax as the first deep-based algorithm was proposed by Bendale & Boult (2016), to replace SoftMax in deep networks. Later, Ge et al. (2017) combined the generative adversarial networks (GAN) with OpenMax and proposed G-OpenMax. Counterfactual image generation proposed by Neal et al. (2018) is the first OSL algorithm to uses the data augmentation technique by generating the unknown classes so that the decision boundaries between unknown and known classes can be figured out. Oza & Patel (2019) used class conditioned auto-encoders to solve OSL problem, and modeled reconstruction errors using the extreme value theory to find the threshold for identifying known/unknown classes.
Theoretical Analysis of OSL
In this section, we introduce the basic notations used in this paper and then provide theoretical analysis for open-set learning. All proofs can be found in Appendices B-E.
Here we introduce the definition of open-set learning (OSL).
Known classes are a subset of . We define the label space of known classes as . Then, the unknown classes are from the space . The open-set learning problem is defined as follows.
Given independent and identically distributed (i.i.d.) samples drawn from . The aim of open-set learning is to train a classifier using such that can classify 1) the sample from known classes into correct known classes; 2) the sample from unknown classes into unknown classes.
where is the weight estimating the importance of unknown classes. When , it is easy to check that
Similarly, given a different joint distribution , we can define and .
Based on -risk, we define almost agnostic probably approximate correct (PAC) for OSL.
Theorems 5 and 6 imply there exists almost agnostic PAC learnable for open-set learning under mild assumptions.
2 Transfer Between Domains
Since there are no samples regarding the unknown classes, we cannot directly analyze the partial risk for unknown classes only using samples from known classes. To analyze the partial risk for unknown classes, we introduce an auxiliary domain , which is used to transfer the information from unknown classes.
A domain defined over is called the auxiliary domain for , if and .
It is clear that and are same if we restrict both of them in the support set of known classes.
Since we do not have any information about samples from unknown classes in the training set, it is unknown whether . In Section 3.3, we will introduce how to construct such that is a uniform distribution. Namely, any sample drawn from has the same probability.
Then, it is interesting to know the discrepancy between and given the same hypothesis . Before doing this, the disparity discrepancy between distributions need to be introduced.
Using the disparity discrepancy, we can show that
is the combined risk for the unknown classes, is the -risk for and is the -risk for .
Theorem 1 implies there exists a gap between and . The gap is related to domain discrepancy for unknown classes between and . To further eliminate the gap between and , additional conditions about the hypothesis space are indispensable.
where is a function defined over and defined as follows , if ; otherwise, .
Assumption 1 implies that the hypothesis space is complexity enough so that the unknown classes can be classified perfectly by many hypothesis functions. The assumption can be regarded as the open-set version of realization assumption (Shalev-Shwartz & Ben-David, 2014; Mohri et al., 2012). Realization assumption is a basic concept in learning theory.
3 Construction of Ideal Auxiliary Domain
As mentioned above, the auxiliary domain plays an important role to address the open-set learning problem from a transfer learning perspective. Thus, in this subsection, we first show how to construct an ideal auxiliary domain and then demonstrate how to estimate the ideal auxiliary domain via finite samples. Given an auxiliary distribution such that , we denote as the density ratio between and , i.e., for any -measurable set ,
and denote as the marginal distribution defined over , i.e., for any -measurable set ,
and is a parameter to tune the density of for unknown classes. Then we define the ideal auxiliary domain.
Given the distribution defined in Problem 1 and an auxiliary distribution defined over such that , then the ideal auxiliary domain regarding to is
where is defined in Eq. (5).
In Definition 5, the probability value of distribution in space is a constant . In detail, if has no overlap between known and unknown classes, any sample from shares same probability (see Figure 1). In addition, an auxiliary distribution satisfying is needed. The samples drawn from can be generated by a gaussian distribution or uniform distribution with suitable support set.
To simple, we provide a mild assumption as follows.
Distributions and introduced in Definition 5 are continuous distributions with density functions and , respectively.
The assumption that and are continuous can be replaced by a weaker assumption: , , where is a measure defined over . With the weaker assumption, all theorems still hold.
Note that the density ratio required in is unknown. To compute the density ratio using and , the density ratio estimation methods are indispensable. Considering the property of statistical convergence, we use kernelized variant of unconstrained least-squares importance fitting (KuLSIF) (Kanamori et al., 2012) to estimate the density ratio in the theoretical part: given RKHS space ,
where is the regularization parameter. Then, we assume is the solution of Eq. (7).
After instance re-weighting, we regard the following measure
as the approximation of , where is defined in Eq. (6),
and is the threshold to select whether a sample is from unknown classes or known classes.
4 Empirical Estimation for IAD Risk
In this subsection, we first set the ideal auxiliary domain as , then we analyze the IAD risk from an approximate view, where \alpha=1-1/\big{(}1+\beta U(r=0)\big{)}. In detail, the IAD risk can be written as follows
Then, we use (see Eq. (8)) to construct auxiliary risk to approximate the IAD risk.
Given samples with size drawn from and with size drawn from , i.i.d., then the auxiliary risk for a hypothesis function is
here is defined in Eq. (8) and is defined in Eq. (6).
Theorem 3 implies that can approximate uniformly.
where is any constant, then for any ,
where denotes the probabilistic order, , is defined in Eq. (10), and is the IAD risk defined in Eq. (9).
Note that , if , and Theorem 3 has indicated that if we omit the term and set , the gap between and is close to by choosing a small .
5 Main Theoretical Results
In this subsection, we analyze the relationship between and based on Theorems 1, 2 and 3.
Given the same conditions and assumptions in Theorems 1 and 3, then for any , ,
Theorem 4 indicates that the gap between and is controlled by four special terms. The combined risk and domain discrepancy for unknown classes can be regarded as constants. The other two terms could be small enough, if and is a small value.
Given the same conditions and assumptions in Theorems 2 and 3, for any , if we assume then has an upper bound
where is defined in Theorem 3, , is defined in Eq. (10) and is the probabilistic order (independent of and ).
If we select a small to make small enough and set , then under some assumptions, the following optimization problem
is almost classifier-consistent The learned classifier by the algorithm is infinite-samples consistent to . with estimation error close to . Additionally, the weight estimation in Theorem 5 is crucial. To weaken the effect of weight estimation in area , we introduce a proxy for .
Given samples with size drawn from and with size drawn from , i.i.d., then the auxiliary risk for a hypothesis function is
where , is defined in Definition 6,
Then, a result similar to Theorem 5 for auxiliary risk is given as follows.
Given the same conditions and assumptions in Theorem 5, for any , if we assume , then has an upper bound
where , are introduced in Theorem 5, and are defined in Definition 7, and is the probabilistic order (independent of and ).
A Principle Guided OSL Algorithm
Inspired by Theorem 6, we focus on the following problem
where is a positive parameter, is defined in Eq. (12), is a hypothesis function based on a neural network, and is parameters of the neural network. To optimize to solve the minimization problem defined in Eq. (13), we have the following five steps.
Step 1 (Feature Encoding). Train the samples to get a closed-set classifier , and designate the output of second to the last layer (without softmax) of as the encoded feature vector, i.e., . The new encoded feature space is denoted as .
Step 2 (Initialize the Auxiliary Domain). Randomly generate samples from space . By default, we generate by uniform distribution and set the size is . We update the samples .
Step 3 (Construct the Auxiliary Domain). Estimate the weights with samples and as the input. The higher the weight is, the more likely a generated sample belongs to the known classes. The parameters selection details are shown as follows.
Weight estimation algorithm: In the theoretical part, KuLSIF is selected to estimate weights. Kernel mean matching (KMM) (Gretton et al., 2012) is also an alternative solution (Cortes et al., 2008). However, in practice, KuLSIF and KMM have time complexity (Kanamori et al., 2012), which is not suitable for large datasets. The kernel bandwidth selection also impacts the overall performance (Liu et al., 2020). Thus, we recommend using the outlier sample score (with range ${O}((n+m)\log(n+m))1$ means known classes while close to means unknown classes.
The is a threshold to split the generated samples into known and unknown samples. Considering we are using iForest, based on the predicted sample score (descending order), we set , where is the proportion that the generated samples selected as unknown samples. We set as default.
The and control jointly the importance of correctly classified unknown samples. We set as a dynamical parameter depending on : , where is number of samples in training samples actually predicted as unknown. For example, if , is , there are samples in training samples are predicted as unknown, then .
Step 4 (). Initialize an open-set learning neural network with samples and as the input and Softmax (Qin et al., 2019) nodes as the output.
Step 5 (Open-set Learning). Train the neural network with the cost function defined in Eq. (13) with both and .
Experiments and Results
First, we implement AOSR on toy dataset with different sample size to reveal the relationship between sample size and error (). Then, we evaluate the efficacy of AOSR on benchmark datasets.
In this paper, we verify the efficacy of algorithm AOSR on double-moon dataset and several real world datasets:
Double-moon dataset (toy). The double-moon dataset consists of two different clusters. Samples from different clusters are regarded as known samples with different label. Samples from other region are regarded as unknown samples drawn from uniform distribution, i.i.d. The ratio between the sizes of known and unknown samples is .
Following the set up in Yoshihashi et al. (2019), we use MNIST (LeCun & Cortes, 2010) as the training samples and use Omniglot (Ager, 2008), MNIST-Noise, and Noise (Liu et al., 2021) datasets as unknown classes. Omniglot contains alphabet characters. Noise is synthesized by sampling each pixel value from a uniform distribution on $10,000$ test samples.
Following Yoshihashi et al. (2019), we use CIFAR- (Krizhevsky & Hinton, 2009) as training samples and collect unknown samples from ImageNet and LSUN. We resized/cropped them so that they would be the same size as the known samples. Hence, we generate four datasets ImageNet-crop, ImageNet-resize, LSUN-crop and LSUN-resize as unknown classes. Each dataset contains test samples.
Following Yoshihashi et al. (2019), Chen et al. (2021), Sun et al. (2020), we use MNIST (LeCun & Cortes, 2010), SVHN (Netzer et al., 2011) and CIFAR- (Krizhevsky & Hinton, 2009) to construct different OSL tasks. For MNIST, SVHN and CIFAR-, each dataset is randomly divided into known classes and unknown classes. In addition, we construct CIFAR+ and CIFAR+ by randomly selection known classes and or unknown classes from CIFAR- (Krizhevsky & Hinton, 2009).
2 Open-set Learning Demonstration
Here we break down the entire learning process and demonstrate the inter-media process of each step on the toy dataset. This experiment is aiming to provide an visualization aid on understanding the open-set learning process.
To start with, we plot the double-moon dataset in Figure 2 (a). The objective of closed-set learning is to build a classifier that can split the samples with different labels. To achieve this goal, we build a simple neural network with sparse categorical cross-entropy as the loss function.
The closed-set learning result is shown in Figure 2 (b). In this case, the closed-set classifier splits the samples with different labels well. However, the closed-set classifier does not consider the boundary of support set for training domain, that is, any new samples that does not located in the support set, the closed-set classifier still gives a known label.
Figure 2 (c) is the open-set learning result. To recognize the unknown samples, the open-set classifier should delineate a boundary between the known and unknown classes. To achieve this goal, we use as the final output and Eq. (13) as the cost function. The AOSR will push the neural network to give label on unknown samples.
3 Experimental Setup
AOSR has several hyper-parameters: , , and . For all tasks, we set as default. is a dynamic parameter depending on . is selected from to . Details on the selection of parameters are available at github.com/Anjin-Liu/Openset_Learning_AOSR.
For datasets MNIST, Omnilot, MNIST-Noise, Noise, we use the same setting of Yoshihashi et al. (2019) and Sun et al. (2020) to extract the features. Same as Yoshihashi et al. (2019), DHRNet- is used as the backbone for CIFAR-, ImageNet and LSUN datasets. For different tasks MNIST, SVHN, CIFAR-, CIFAR+ and CIFAR+, the backbone is the re-designed VGGNet used by Yoshihashi et al. (2019) and Sun et al. (2020).
We select baseline algorithms as follows: SoftMax, OpenMax (Bendale & Boult, 2016), Counterfactual (Neal et al., 2018), CROSR (Yoshihashi et al., 2019), C2AE (Oza & Patel, 2019), and CGDL (Sun et al., 2020).
4 Evaluation
Following Yoshihashi et al. (2019), the macro-average F1 scores are used to evaluate OSL. The area under the receiver operating characteristic (AUROC) (Neal et al., 2018) is also frequently used (Neal et al., 2018; Chen et al., 2020). Note that AUROC used in (Neal et al., 2018; Chen et al., 2020) is suitable for global threshold-based OSL algorithms that recognize unknown samples by a fix threshold (Neal et al., 2018). However, AOSR recognizes unknown samples based on the score of hypothesis function, thus, AOSR uses different thresholds for different samples. This implies that AUROC used in (Neal et al., 2018; Chen et al., 2020) may be not suitable for our algorithm. In this paper, we use macro-average F1 scores to evaluate our algorithm.
5 Experimental Evaluation and Result Analysis
Experiment results on double-moon dataset are summarized in Figure 2 (d). We implement double-moon dataset with varying size select from . We also generate test samples. For a different sample size, we run times and report the mean accuracy and standard error in Figure 2 (d). Based on Figure 2 (d), the accuracy increases as the increase of training sample size increases. When , the accuracy approximates at . In particular, the green curve and the yellow curve jointly control the curve of accuracy, implying the error of AOSR is controlled by .
Experiment results on real datasets are summarized in Tables 1, 2 and 3. For all tasks, we run AOSR times and report the mean results by using F1 score (Powers, 2020). In general, AOSR shows the promising performance when compared to baseline algorithms. The effectiveness of AOSR indicates that our theory is effective and practical.
Parameter analysis for and is given in Figure 2 (e), (f). We run AOSR with varying values of on MNIST tasks. From Figure 2 (e), we observe that 1) when increases from to , the F1 scores for Noise and MNIST-Noise decrease; 2) as increasing from to , the F1 score for Omniglot increases. When , the performance for Omniglot dramatically dropped to baseline. Additionally, according to Figure 2 (f), we find that by changing in the range of , AOSR achieve stable performance.
Ablation study on datasets MNIST, Omnilot, MNIST-Noise and Noise is shown in Table 4. By adjusting different components of AOSR, Table 4 indicates that each component of AOSR is important and necessary. Note that if we replace iForest by KMM in AOSR, the performance () is close to AOSR (). This implies that KMM may be a good choice, if we omit the time complexity of KMM.
Discussion
Relation with Generative Models. Algorithms based on generative models are the mainstream for OSL. CGDL (Sun et al., 2020), C2AE (Oza & Patel, 2019) and Counterfactual (Neal et al., 2018) are the representative works based on generative models. AOSR can be regarded as the weight-based generative model, but is very different from the mainstream generative model-based algorithms (feature map-based generative model (Sun et al., 2020; Oza & Patel, 2019; Neal et al., 2018)). Form the theoretical perspective, it is necessary to develop theory to guarantee the generalization ability of feature map-based generative models. Here we propose an interesting and important problem: how to develop generalization theory for feature map-based generative models under open-set assumption ?
Relation with PU Learning. Positive-unlabeled learning (PU learning) (Niu et al., 2016) is a special binary classification task, which assumes only unlabeled samples and positive samples (i.e., samples with positive labels) are available. Our theory is deeply related to PU learning. If we regard the known samples and the auxiliary samples as the positive samples and the unlabeled samples, respectively. Then, our theory degenerates into the PU learning theory.
Remaining Problems in OSL Theory. We list several interesting and important problems for OSL theory as follows. 1. How to construct weaker assumption to replace assumption 1 for achieving similar results ? 2. Without assumption 1, what will happen ? 3. Is it possible for OSL to achieve agnostic PAC learnability and achieve fast learning rate , for ? 4. Is it possible to construct OSL learning theory by stability theory (Bousquet & Elisseeff, 2002) ?
Conclusion and Future Work
This paper mainly focuses on the learning theory for open-set learning. The generalization error bounds proved in our work provide the first almost-PAC-style guarantee on open-set learning. Based on our theory, a principle guided algorithm AOSR is proposed. Experiments on real datasets indicate that AOSR achieves competitive performance when compared with baselines. In future, we will focus on developing more powerful OSL algorithms based on our theory and dynamic weight technique (Fang et al., 2020a). With the dynamic weight , we can update the weight for each epoch and make a better integration between instance-weighting and deep learning.
Acknowledgments
The work introduced in this paper was supported by the Australian Research Council (ARC) under FL190100149.