A PAC-Bayesian bound for Lifelong Learning
Anastasia Pentina, Christoph H. Lampert
Introduction
Today, many problems can be solved equally well or better by machine learning algorithms as by humans. However, these algorithms typically require large amount of training data to achieve acceptable results, whereas humans are able to learn new concepts from just a few examples. Presumably this difference comes from the fact that most machine learning systems are trained from scratch for each task at hand, whereas humans exploit context and knowledge they acquired previously while solving other tasks.
This observation motivates research on transfer learning: how can information from previously learned tasks be used for solving new tasks? Several scenarios of how this question can be formalized have been identified. Here, we discuss some that are most relevant in the context of supervised learning. As general setup, one assumes that one or more learning tasks have been observed, typically in form of labeled training sets. The methods then differ in how this information is meant to be used. In the multitask setting (Caruana, 1997), the goal is simply to perform well on all of the tasks. In domain adaptation (Bridle & Cox, 1990), the goal is to perform well on a new task for which only unlabeled or very few labeled data samples are observed. Finally, in lifelong learning or learning to learn (Thrun & Mitchell, 1995), the goal of the learner is to perform well on future tasks, for which so far no data has been observed. In this work we focus on the third setting.
For lifelong learning to make sense, one must assume a relation between the observed tasks and the future tasks. To formalize this, Baxter (2000) introduced the notion of a task environment as a set of possible tasks that might need to be solved at some time. The observed tasks are sampled randomly from the environment according to an unknown task distribution. In this setting, Baxter also provided the first theoretical guarantees by proving generalization bounds in the framework of VC theory (Vapnik, 1998). After this work, however, progress on the theoretical understanding of lifelong machine learning slowed down. Many algorithms for transfer learning were developed and found empirically to work well in many cases. However, except for a few exception, such as (Maurer, 2009; Maurer et al., 2013), their theoretical justifications are so far not well understood.
In this work, we aim at making progress on the theoretical justifications of lifelong learning. In Section 2 we prove a general PAC-Bayesian generalization bound for lifelong learning that allows quantifying the relation between the expected loss on a future learning task to the average loss on the observed tasks. In contrast to Baxter’s results, our bound has the advantage that its value depends on the representation of the data and on the learning algorithm used to solve the tasks. This makes it possible to interpret the bound as a quality measure of the transferred information. Therefore, by optimizing the measure we obtain principled algorithms for lifelong learning.
In Sections 2.1 and 2.2 we demonstrate this process in two cases: assuming that the solutions to all tasks can be represented by a single parameter vector plus small task-specific perturbation (Evgeniou & Pontil, 2004), we obtain an algorithm that resembles previously proposed methods for regularizing the weight vectors of future tasks using linear combinations of weight vectors of previous tasks, such as (Yang et al., 2007; Aytar & Zisserman, 2011).
An alternative assumption is that the solution vectors to tasks can differ significantly, but that they all lie in a common feature subspace of low dimension. In this setting, our bound provides an algorithm in which the observed tasks are used to identify the most promising subspace of features, such that learning for future tasks needs to take place only within the reduced feature space. This procedure is related to existing methods for representation and dictionary learning, e.g. (Argyriou et al., 2008; Kumar & Daumé III, 2012), which have also successfully been applied in the lifelong learning setting (Ruvolo & Eaton, 2013). In a case of linear regression, Maurer (2009) used this assumption to prove a generalization bound in the PAC framework, by using the concept of environment of tasks from Baxter (2000) and Rademacher complexity. Similar results were obtained in (Maurer et al., 2013) in the case of sparsity constraints.
The PAC-Bayesian framework.
For the convenience of readers who are not familiar with the PAC-Bayesian framework, we introduce the most relevant concepts from the literature here. For more details, see (Langford, 2005; Seeger, 2003; Catoni, 2007).
PAC-Bayesian theory studies the properties of randomized predictors, called Gibbs predictors. Formally, let be an input set, an output set and a set of prediction functions (hypotheses). For any probability distribution over , the Gibbs predictor associated with is the stochastic predictor that for any randomly samples a hypothesis and then returns .
where is a reference or prior distribution over that must be chosen before observing the samples , and is the Kullback-Leibler divergence, i.e. a measure how different is from . As such, the bound resembled the typical trade-off in regularized risk minimization between the training loss and a regularizer (Vapnik, 1998).
Inequality (1) is uniform with respect to , so it holds regardless of which we choose. In particular, we can choose it after seeing , and for this reason is typically referred to as posterior distribution in this context.
Choosing such that it minimizes the right hand side of the bound we obtain a Gibbs predictor that can be expected to be a good choice for the learning task at hand, since its expected loss is controlled by a hopefully small quantity. While the inequality (1) holds regardless the agreement between the data distribution and the prior distribution , the value of the right hand side of the bound strongly depends on the choice of . Therefore, one would prefer a prior that allows learning a posterior that is at the same time close to the prior ( is small) and shows good performance on the training set ( is small).
PAC-Bayesian Lifelong Learning
The goal of the agent is to use the information contained in the observed tasks to identify prior knowledge that will cause as good as possible performance on new (so far unobserved) tasks from the same environment. This setting is strictly harder than multi-task learning or domain adaptation, since no data for the future tasks to be solved is available at the time the agent makes its decision. In particular, previously developed techniques for learning priors are not directly applicable: first, note that we cannot use ordinary generalization bounds, such as (1), to identify optimal priors, since they only hold uniformly in if the prior is chosen independently from the training set. Catoni (2007) derived an expression for the overall ”best” prior, i.e. the distribution resulting in the smallest possible bound value. However, it is generally of a non-parametric form and uncomputable without full information about the data distribution. Parrado-Hernández et al. (2012) showed that priors can be learned by splitting the available training data into two parts, one for learning a prior, one for learning the predictor. This, however, requires training data for the task at hand, which is not available in the lifelong setting.
Our first contribution in this work is the insight that one should treat the prior itself as a random variable. Let be an initial distribution over all possible priors, which we call hyperprior in concordance with the Bayesian nomenclature. For learning a prior the agent uses the observed tasks to adjust its original hyperprior into a hyperposterior distribution over the set of priors. This randomized setting allows us to follow a PAC-Bayesian path analogous to classical results. We will obtain a bound that requires a fixed hyperprior but that holds uniformly with respect to the hyperposterior . The hyperposterior that minimizes the bound will provide us with the most promising distribution from which to obtain priors for future tasks.
Formally, the goal of the agent is to find that minimizes the expected loss of a randomly sampled new task with training set and prior sampled from . We write
where is the posterior obtained by training the learning algorithm with prior and training sample . We call this quantity the transfer risk.
We cannot compute because the distributions over the tasks and the tasks’ data are both unknown. However, we can approximate it by its empirical counterpart, based on observed tasks
Our main result is a theorem that bounds the difference between the two quantities defined above.
For any the following inequality holds with probability at least (over the training samples ) for all hyperposterior distributions
where denotes the distribution in which we first sample according to and then use it and the data to produce a posterior for each task . denotes the distribution in which we sample according to and use it as a posterior for all tasks. is the harmonic mean of the sample sizes.
Proof To prove Theorem 1 we introduce an intermediate quantity that can be seen as an expected multi-task risk
First we will bound the uncertainty on the task environment level by bounding the difference between transfer error, , and expected multi-task error, . Then we will bound the uncertainty within observed tasks by bounding the difference between expected multi-task error, , and its empirical approximation, . Our main tool in both cases will be the following lemma.
Let be a random variable taking values in and let be independent random variables with each distributed according to over the set . For functions , let for any fixed value of . Then for any fixed distribution on and any the following inequality holds with probability at least (over sampling ) for all distributions over
For the proof of this lemma, see the Appendix A.
In order to bound the difference between and we treat each task with the corresponding training sample as a random variable and apply Lemma 2. Formally, we set , , , , and and apply Lemma 2 with . Since and we obtain with probability at least that for all
Now (4) follows by a union bound from (7) and (8). To get a better understanding of Theorem 1, we rewrite (4) in the following way:
We see that the bound contains two types of complexity terms that correspond to two levels of our model: belongs to the level of task environment in general, while each corresponds specifically to the -th task.
To better understand their roles, we look at the following limit cases: when the agent has access to sufficiently many tasks () but tasks come with a finite amount of data ( is finite), the first complexity term converges to as . The second complexity term converges to an average -divergence over tasks and may therefore remain non-zero. This means that observing many task gives the agent full knowledge about the task environment, but it cannot overcome the uncertainty within each task. In the opposite case, if the agent observes unlimited data for each tasks, but only for a finite number of tasks (, is finite), the second complexity term converges to as , while the first one does not, so there is still uncertainty on the task environment level. Only when both comes together, sufficiently many tasks and sufficient amounts of data per task, it is guaranteed that the empirical multi-task risk converges to the transfer risk .
A second important aspect of Theorem 1 is that the bound (4) consists only of observable quantities. Therefore, we can treat it as a quality measure for hyperposteriors . By minimizing it, we obtain a hyperposterior distribution over priors that is adjusted to the particular environment of learning tasks. Since the bound holds uniformly with respect to , the guarantees of Theorem 1 also hold for the resulting learned hyperposterior, so we can expect priors sampled according to the learned hyperposterior to work well even for future tasks.
In the following sections, we discuss two instantiations of this procedure and show how they relate to previous work on transfer learning.
where is some function of weight vectors of previously observed tasks, e.g. just their average, .
Theorem 1 allows us to learn an “optimal” from the data, instead of fixing the rule for computing it. For this, we choose and , i.e. unit variance normal distributions with means and , respectively. The mean is a random variable distributed first according to the hyperprior distribution, , which we set as and later according to the hyperposterior, , which we model as . The task of the learning consists of identifying the best .
As underlying learning algorithm we use Equation (10) with regularizer centered at a prior vector. For any and training set the posterior, , is given by
where is the matrix with columns , is a column of labels , and .
Computing the complexity terms from (9) we obtain
We insert Equations (13) into the inequality (9) and obtain
where \Phi(z)=\frac{1}{2}\big{(}1-\operatorname{erf}(\frac{z}{\sqrt{2}})\big{)} and is the Gauss error function.
For a practical algorithm, one typically would prefer a bound on the loss of a deterministic classifier rather than of the stochastic Gibbs classifier. For -loss Theorem 1 provides this, since the Gibbs error is at most twice smaller than the expected error of the classifier defined by (McAllester, 2003; Laviolette & Marchand, 2007). Inserting (15) in (14) and multiplying the left hand side by we obtain the following inequality:
Minimizing the right hand side of (16) or (17) with respect to , we obtain a data-dependent hyperposterior that induces prior distributions that are adjusted optimally (in the sense of the bound) to the task environment.
2 Representation Transfer
A second assumption commonly made in multitask or lifelong learning is that the weight vectors for all tasks lie in low-dimensional subspace. Theorem 1 also allows us to learn such a subspace in a principled way.
where . The only free parameter is , i.e. a matrix with that represents the ”most promising subspace”. Equation (19) can be interpreted as an analog of the Gaussian distribution on , with mode and unit variance. In the special case of , it reduces to the better known Von Mises distribution on the unit circle (Downs, 1972).
As in the previous section we use Gaussian distributions for prior and posterior, but defined only within the subspaces sampled from or . For the prior, , we choose a Gaussian with zero mean and variance . The posterior, , is a shifted Gaussian with variance and mean in the same subspace. As in the previous section we use ridge regression as learning algorithm, but again only within the subspace determined by the prior,
where is the matrix representing the subspace, such that is the projected representation of the training data in this subspace.
where . We see that a representation, , can be considered promising for future tasks, if itself as well as the subspaces close to it allow classification with small loss and small weight vector norm (i.e. large margin) for all observed tasks.
Experiments
In this section, we demonstrate how learning priors distributions by minimizing the bounds (16), (17) and (2.2) can improve prediction performance in real prediction tasks. To position our results with respect to previous work on parameter and representation transfer, we compare to adaptive ridge regression (ARR), i.e. Equation (10) the prior set to the average of the weight vectors from the observed tasks, and with the ELLA algorithm (Ruvolo & Eaton, 2013) that learns a subspace representation using structured sparsity constraints, also with squared loss. We also report results for ordinary ridge regression without any knowledge transfer.
We perform experiments on three public datasets:
Land Mine Detection (Xue et al., 2007). This dataset consists of 14820 data points. For each data point there are 9 features extracted from radar images and a binary label or corresponding to landmine or clutter. We also add a bias term, resulting in features. Data points are collected from 29 geographical regions and we treat each region as a binary classification task.
London School Data. This is a regression dataset, containing exam scores of 15362 students from 139 schools. Each student is described by 4 school-specific, 3 student-specific features and a year of examination. We use the same procedure as in (Argyriou et al., 2008; Kumar & Daumé III, 2012; Ruvolo & Eaton, 2013) to encode them in a set of binary features. We also add a bias term, so the final data dimensionality is . Each school constitutes a task.
Animals with Attributes Dataset (Lampert et al., 2013). This dataset contains 30475 images from 50 classes. Each image comes with a 2000-dimensional feature vector, that we reduced to 100 dimensions using PCA. We -normalize the resulting feature vectors and add a bias term. We select the largest class, collie, and form 49 binary classification tasks, each of them is a classification of collie versus one of the remaining classes. For each task we use of the data (approximately 20 images) available for collie class and the same amount of images from the another task, such that data between different tasks does not overlap.
We first perform experiments on prior learning in the setup of parameter transfer, as described in Section 2.1, calling the resulting algorithm Prior Learning with Gaussian hyperprior (PL-G). For the classification tasks (Landmine and Animals), we optimize the bound (16). To do so we replace by its convex relaxation, , if and otherwise, and use the conjugate gradient method for finding the minimum.
For the regression tasks (Schools) we first divide labels (examination scores) by their maximum value. This allows us to assume that the squared loss will not exceed . We optimize (17), and due to the squared loss, the problem has a closed form solution:
To make results comparable with the baseline algorithms, we report the squared error multiplied by the squared value of the maximum examination score.
2 Representation Transfer
In a second set of experiments, we implement the idea of representation transfer from Section 2.2, calling the algorithm Prior Learning with Langevin hyperprior (PL-L).
As in the case of parameter transfer, we use loss to measure the quality in classification tasks. For the regression task we apply the same scaling procedure as discussed in Section 3.1 and use truncated squared loss. Both of these loss functions can be upper-bounded by the standard squared loss, which we do to obtain tractable expressions for the right hand side of the Inequality (2.2). To be able to optimize the expression (2.2) numerically, we approximate it by replacing all expectations over by their values at its mode, . Furthermore, we replace the error of any Gibbs predictor by the error of the deterministic predictor defined by the mode of the posterior distribution, . The result is a quadratic optimization problem over the Stiefel manifold, which we solve using gradient descent with curvilinear search (Wen & Yin, 2013).
3 Evaluation procedure
To get reliable estimates of the transfer risk, we repeat the following experimental procedure 100 times for each dataset and calculate the mean prediction errors and standard errors of the mean.
In each experiment, we set aside a subset of tasks as unobserved (9 in Landmines, 39 in Schools, 9 in Animals). These are not used during any part of training, but only to evaluate the methods on ”future” tasks. Of the remaining tasks we use different fractions to measure the effect of a different number of observed tasks. The algorithms described in Section 3.1 and 3.2 and ARR have one free parameter, the regularization strength . We choose this using 3-fold cross-validation in the following way. We split the data of each task into three parts: we use the first third of all tasks jointly to learn a prior. To evaluate this prior, we then train individual predictors using the second part of the data, and test their quality on the third part. For the ELLA algorithm, we use the same procedure to set the regularization strength , the remaining parameters we leave at their default values. For the baseline, we set the regularization using ordinary 3-fold cross-validation.
4 Results
The results of the experiments on all three datasets are shown in Figure 1. Since classes in Landmine dataset are unbalanced, for this problem we report the value of area under the ROC curve (AUC, bigger value means better prediction). Tasks in the Animals dataset are balanced, so for them we report the standard mean error. Since the dataset was too large for the subspace methods, we only report results for the parameter transfer techniques. For the experiment on Schools dataset we report the mean squared error (MSE, smaller values mean better prediction).
As a first observation, Figure 1 confirms the findings of previous work that better prediction can be achieved by transferring information from related tasks. Overall, it shows that PL-G and PL-L are comparable to the existing, manually designed, techniques. Given sufficiently many tasks, they are able to improve the prediction accuracy over the baseline. As an illustration of the hyperprior concept, we show results for PL-G with two different values for the Gaussian hyperprior variance (Figures 1(a), 1(b), 1(c)). For , the adaption pursues in a very conservative way and many tasks are needed to find a reliable hyperposterior. With , convergence is faster, and PL-G achieves results comparable with ARR or even slightly better. For practical tasks, the hyperprior should possibly be chosen by model selection.
The results for representation transfer (Figures 1(d) and 1(e)) show that the improvements achieved by PL-L are comparable to the ELLA algorithm. As in the case of parameter transfer, we show results for two different values of the Gaussian prior variance: and . While for the Landmine dataset (Figure 1(d)), there is no significant difference in the performance for different values of parameters and , for the Schools dataset (Figure 1(e)) the choice of these parameters plays a bigger role. We see that the improvements of PL-L with are almost the same as the one achieved by ELLA, while for they are smaller. This might be the effect of too strict hyperparameters that cause the method to be more conservative than necessary. Another possible reason for the difference in accuracy is that ELLA makes additional sparsity assumption, which PL-L does not.
Conclusion
In this work we studied lifelong learning from a theoretical perspective. Our main result is a generalization bound in a PAC-Bayesian framework (Theorem 1). On the one hand, the bound is very general, allowing us to recover two existing principles for transfer learning as special cases: the transfer of classifier parameters, and the transfer of subspaces/representations. On the other hand, the bound consists only of observable quantities, such that it can be used to derive principled algorithms for lifelong learning that achieve results comparable with existing manually designed methods.
A further use of the bound we see is in using it to study the implicit assumptions of possible learning methods. For example, a method obtained by means of a unimodal hyperposterior will require all tasks to be related to each other. In future work, we plan to explore the potential of integrating more realistic assumptions, such as hierarchical or multi-modal hyperposteriors. A second interesting direction will be to relax the condition that tasks are sampled i.i.d. from an environment, e.g. into the direction of learning tasks of continuously improving difficulty (Bengio et al., 2009).
We thank Shai Ben-David, Olivier Catoni and Emilie Morvant for helpful discussions. This work was in parts funded by the European Research Council under the European Union’s Seventh Framework Programme (FP7/2007-2013)/ERC grant agreement no 308036.
Appendix A Proof of Lemma 2
In the proof we will make use of Hoeffding’s Lemma:
(Hoeffding, 1963) Let be a real-valued random variable such that and let . Then
We will also require the following property of the Kullback-Leibler divergence that holds for any and can be proved by convex duality (Seeger, 2003):
We now prove Lemma 2. First, we apply (25) to , obtaining
since for any fixed the factors are independent. This allows us to apply Hoeffding’s Lemma 3 to each factor:
By taking the expectation over we obtain
Since is fixed and does not depend on , we can exchange the order of expectations. By applying Markov’s inequality with respect to expectations over we obtain that with probability at least :
We obtain (2) by combining (30) and (26).