An Information-Theoretic Approach to Transferability in Task Transfer Learning

Task transfer learning is a popular technique in image processing applications that uses pre-trained models to reduce the supervision cost of related tasks. An important question is to determine task transferability, i.e. given a common input domain, estimating to what extent representations learned from a source task can help in learning a target task. Typically, transferability is either measured experimentally or inferred through task relatedness, which is often defined without a clear operational meaning. In this paper, we present a novel metric, H-score, an easily-computable evaluation function that estimates the performance of transferred representations from one task to another in classification problems using statistical and information theoretic principles. Experiments on real image data show that our metric is not only consistent with the empirical transferability measurement, but also useful to practitioners in applications such as source model selection and task transfer curriculum learning.


Introduction
Transfer learning is a learning paradigm that exploits the relatedness between different learning tasks in order to gain certain benefits, e.g. reducing the demand for supervision ([1]). In task transfer learning, we assume that the input domain of the different tasks are the same. Then for a target task T T , instead of learning a model from scratch, we can initialize the parameters from a previously trained model for some related source task T S (Figure 1). For example, deep convolutional neural networks trained for the ImageNet classification task have been used as the source network in transfer learning for target tasks with fewer labeled data [2], such as medical image analysis [3] and structural damage recognition in buildings [4]. An imperative question in task transfer learning is transferability, i.e. when a transfer may work and to what extent. Given a metric capable of efficiently and accurately measuring transferability across arbitrary tasks, the problem of task transfer learning, to a large extent, is simplified to search procedures over potential transfer sources and targets as quantified by the metric. Traditionally, transferability is measured purely empirically using model loss or accuracy on the validation set ([5, 6, 7]). There have been theoretical studies that focus on task relatedness ([8, 9, 10, 11]). However, they either cannot be computed explicitly from data or do not directly explain task transfer performance. In this study, we aim to estimate transferability analytically, directly from the training data.
We quantify the transferability of feature representations across tasks via an approach grounded in statistics and information theory. The key idea of our method is to show that the expected log-loss of using a feature of the input data to predict the label of a given task under the probabilistic model can be characterized by an analytically expression, which we refer as the H-score of the feature. H-score is particularly useful to quantify feature transferability among tasks. Using this idea, we define task transferability as the normalized H-score of the optimal source task feature with respect to the target task.
As we demonstrate in this paper, the advantage of our transferability metric is threefold. (i) it is theoretically driven and has a strong operational meaning rooted in statistics and information theory; (ii) it can be computed directly and efficiently from the input data, with fewer samples than those needed for empirical learning; (iii) it can be shown to be strongly consistent with empirical transferability measurements.

Measuring Feature Effectiveness
Let X and Y denote the input and output space respectively. Denote the transferred feature representation by f : X → R k .
For a classification task, let h f : X × Y → [0, 1] |Y| be a predictor function with the log-loss function L(f (x), y) for a given (x, y) sample. The traditional machine learning approach uses stochastic gradient descent to minimize L(h) = E X,Y [L(f (x), y)]. We will show that the optimal log loss when f is given can be characterized analytically using concepts in information theory and statistics.
Definition 1. The Divergence Transition Matrix (DTM) of discrete random variables X and Y is a |Y| by |X | matrixB with entriesB y,x = Using concepts in Euclidean information geometry, it is shown in [12] that under a local assumption, for a given feature dimension k, (1) reveals a close connection between the optimal log-loss and the modal decomposition ofB. In consequence, it is reasonable to measure the classification performance with B − ΨΦ T 2 F given f (X). i.e. Since Φ is fixed, we can find the optimal Ψ , Ψ * by taking the derivative of the objective function with respect to Ψ: (2) Substituting (2) in the Objective of (1), we can derive the following close-form solution for the log loss: (3) The first term in (3) does not depend on f (X), therefore it is sufficient to use the second term to estimate classification performance with transferred feature f . We can further rewrite ||BΦ(Φ T Φ) − 1 2 || 2 F as follows and denote it as the H-score.
Definition 2. Given data matrix X ∈ R m×d and label Y , let f (X) be a k-dim, zero-mean feature function. The H-Score of f with respect to a task with joint probability P Y X is: The derivation of (4) can be found in Section 1 of the Supplementary Material 1 . This formulation can be intuitively interpreted from a nearest neighbor perspective. i.e. a high H-score implies the inter-class variance cov(E P X|Y [f (X)|Y ]) of f is large, while feature redundancy tr(cov(f (X))) is small. Comparing to finding the optimal log-loss through gradient descent, H-score can be computed analytically and only requires estimating the conditional expectation E[f (X)|Y ] from sample data. Moreover, H(f ) has an operational meaning that characterizes the asymptotic error probability of using f (X) to estimate Y in the hypothesis testing context. (See Section 2 in the Supplementary Material for details).
The upper bound of H(f ) is obvious from its first definition: We call features that achieve this bound the minimum error probability features for a given task.

Transferability
Next, we apply H-score to efficiently measure the effectiveness of task transfer learning. We will use subscripts S and T to distinguish variables for the source and the target tasks.
Definition 3 (Task transferability). Given source task T S , target task T T and pre-trained source feature f S (x), the transfer- is the minimum error probability feature of the target task.
This definition implies 0 ≤ T(S, T ) ≤ 1. With a known f , computing H-score from m sample data only takes O(mk 2 ) time, where k is the dimension of f (x) for k < m. The majority of the computation time is spent on computing the sample covariance matrix cov(f (X)).
The remaining question is how to obtain H T (f Topt ) efficiently. This question has been addressed in [13], which shows that ||B T || 2 ], where f and g are the solutions of the HGR-Maximum Correlation problem.
ρ(X; Y ) = sup Eq. (6) can be solved efficiently using the Alternating Conditional Expectation (ACE) algorithm [14] for discrete X , or using the neural network approach based on Generalized Maximal HGR Correlation [15] for a generic X . The sample complexity of ACE is only 1/k of the complexity of estimating P Y X directly [16]. This result also applies to the Generalized HGR problem due to their theoretical equivalence. A common technique in task transfer learning is finetuning, which adds before the target classifier additional free layers, whose parameters are optimized with respect to the target label. For the operational meaning of transferability to hold exactly, we require the fine tuning layers consist of only linear transformations. Nevertheless, later we will demonstrate empirically that this transferability metric can still be used for comparing the relative task transferability with fine-tuning. In many cases though, the computation of H T (f opt ) can even be skipped entirely, such as the problem below: Definition 4 (Source task selection). Given N source tasks T S1 , . . . , T S N with labels Y S1 , . . . , Y S N and a target task T T with label Y T . Let f S1 , . . . , f S N be optimal representations for the source tasks. Find the source task T Si that maximizes the testing accuracy of predicting Y T with feature f Si .
We can solve this problem by selecting the source task with the largest transferability to T T . In fact, we only need to compute the numerator in the transferability definition since the denominator is the same for all source tasks, i.e. argmax i T(S i , T ) = argmax i H(f Si ).

Experiments
In this section, we present validation results and potential application of our transferability metric on real image data. (For implementation details, see Section 3 of the Supplementary Material.)

Validation of transfer performance
We validate H-score and transferability definitions in a transfer learning problem from ImageNet 1000-class classification (ImageNet-1000) to Cifar 100-class classification (Cifar-100). Figure S2.a compares the H-score and empirical performance of transferring from five different layers (4a-4f) of the ResNet-50 model pretrained on ImageNet1000. As H-score increases, log-loss of the target network decreases almost linearly while the training and testing accuracy increase, which validates the relationship between the expected log-loss and H-score. The training and testing accuracy are also positively correlated with H-score. It also shows that H-score can be applied for selecting the most suitable layer for fine-tuning in transfer learning.
We further tested our transferability metric for selecting the best target task for a given source task. In particular, we constructed 4 target classification tasks with 3, 5, 10, and 20 object categories from the Cifar-100 dataset. We then computed the task transferability from ImageNet-1000 (using the feature representation of layer 4f) to the target tasks. In Figure2.b, we observe a similar behavior as the H-score in the case of a single target task in Figure 2.a, showing that transferability can directly predict the empirical transfer performance.

Task transfer for 3D scene understanding
Next, we apply our transferability metric to solve the source task selection problem among 8 image-based recognition tasks for 3D scene understanding using the Taskonomy dataset [6]. We also compared the task transferability ranking based on H-score with the ranking using task affinity, an empirical transferability metric proposed by [6] with non-linear fine tuning.
For a fair comparison, we use the same trained encoders in [6] to extract source features with dimension k = 2048. It's worth noting that, six of eight tasks have images as their output. To compute the transferability for these pixel-to-pixel tasks, we cluster the pixel values of the output images in the training data into a palette of 16 colors and then compute the H-score of the source features with respect to each pixel. The transferability of the task is computed as the average of the H-scores over all pixels. For larger images, H-score can be evaluated on super pixels instead of pixels to improve efficiency.  Fig. 3: Ranking comparison between transferability and affinity score.
Pairwise Transfer Results. Source task ranking results using transferability and affinity are visualized side by side in Figure 3, with columns representing source tasks and rows representing target tasks. For classification tasks (the bottom two rows in the transferability matrix), the top two transferable source tasks are identical for both methods. Similar observations can be found in 2D pixel-to-pixel tasks (top two rows). A slightly larger difference between the two rankings can be found in 3D pixel-to-pixel tasks, especially 3D Occlusion Edges and 3D Keypoints. Though the top four ranked tasks of both methods are exactly the four 3D tasks. It could indicate that these low level vision tasks are closely related to each other so that the transferability among them are inherently ambiguous. We also computed the ranking correlations between transferability and affinity using Spearman's R and Discounted Cumulative Gain (DCG). Both criterion show positive correlations for all target tasks. The correlation is especially strong with DCG as higher ranking entities are given larger weights.
To show the task relatedness, we represent each task with a vector consisting of H-scores of all the source tasks for the given task, then apply agglomerative clustering over the task vectors. As shown in the dendrogram in Figure 3, 2D tasks and most 3D tasks are grouped into different clusters, but on a higher level, all pixel-to-pixel tasks are considered one category compared to the classifications tasks. Higher Order Transfer. A common way for higher order transfer is to concatenate features from multiple models in deep neural networks. Our transferability definition can be easily adapted to such problems. Figure 4 shows the ranking results of all combinations of source task pairs for each target task. For all tasks except for Edge3D and Depth, the best seond-order source feature is the combination of the top two tasks of the first-order ranking. We examine the exception in Figure 5, by visualizing the pixel-by-pixel H-scores of first and second order transfers to Depth using a heatmap (lighter color implies a higher H-score). Note that different source tasks can be good at predicting different parts of the image. The top row shows the results of combining tasks with two different "transferability patterns" while the bottom row shows those with similar patterns. Combining tasks with different transferability patterns has a more significant improvement to the overall performance of the target task.

Task transfer learning curriculum
A potential application of our transferability metric is developing an optimal task transfer curriculum, a directed acyclic graph over tasks that specifies the order in which to obtain labeled data for each task. For each task in the curriculum, an optimal feature representation can be learned using both its raw input and the representations of its parent tasks to improve  training efficiency. We use a heuristic based on the minimum spanning tree of a task graph, whose edge weights are inversely correlated with the larger transferability score between two tasks. Fig. 7.a shows the task curriculum for the eight tasks in Section 4.2. Furthermore, we did a similar experiments on a collection of binary object classification tasks using the NUS-WIDE multi-label dataset [17] (Fig. 7.b). We set a threshold to find the most salient transfers and the resulting curriculum is in line with human perception.

Conclusion
In this paper, we presented H-score, an information theoretic approach to estimating the performance of features when transferred across classification tasks. Then we used it to define a notion of task transferability in multi-task transfer learning problems, that is both time and sample complexity efficient. Our transferability score successfully predicted the performance for transfering features from ImageNet-1000 classification task to Cifar-100 task. Moreover, we showed how the transferability metric can be applied to a set of diverse computer vision and image-based recognition tasks using the Taskonomy and NUS-WIDE datasets. In future works, we will investigate properties of higher order transferability, developing more scalable algorithms that avoid computing the H-score of all task pairs. We also hope to design better task curriculum for task transfer learning in practical applications.
("TRI") provided funds to assist the authors with their research but this article solely reflects the opinions and conclusions of its authors and not TRI or any other Toyota entity.
[ [4] Yuqing Gao and Khalid M Mosalam, "Deep transfer learning for image-based structural damage recognition," Computer-Aided Civil and Infrastructure Engineering.
Supplementary Material S1 Derivation of Equation (4) First, we need to introduce some additional notations. Let X, x, X and P X represent a random variable, a value, the alphabet and the probability distribution respectively. √ P X denotes the vector with entries P X (x) and [ √ P X ] ∈ R |X |×|X | denotes the diagonal matrix of √ P X . For joint distribution P Y X , P Y X ∈ R |Y|×|X | represents the probability matrix. Given k feature functions f i : X → R, i = 1, ..., k, let f (x) = [f 1 (x), ..., f k (x)] ∈ R k be the feature vector of x, and F = [f (x 1 ) T , ..., f (x |X | ) T ] T ∈ R |X |×k be the feature matrix over all elements in X .
The left hand side of Equation (4) can be expressed as Since any feature function can be centered by subtracting the mean, without the loss of generality, we assume E[f (X)] = 0.
Using the one-to-one correspondence between Φ and F , i.e. Φ = √ P X F ∈ R |X |×k , we have = cov(f (X)) (7) The DTM matrixB introduced in Definition 1 can be written in matrix notation: where 1 is a column vector with all entries 1 and length |Y|. It follows that, =cov (E[f (X)|Y ]) (8) By substituting (7) and (8)

S2 Operational Meaning of H-Score
In this section, we will show that H-score characterizes the asymptotic probability of error in the hypothesis testing context. We will start with some background on error exponents from statistics, then explain how to estimate it using informa- Fig. S1: The binary hypothesis testing problem. The blue curves shows the probility density functions for P 1 and P 2 . The rejection region A c and the acceptance region A are highlighted in red and blue, respectively. The vertical line indicates the decision threshold.
tion geometry. Finally, we will show how computing H-score is in fact estimating the error exponent of a feature function on the sample data.

S2.1 Error Exponent and Hypothesis Testing
Consider the binary hypothesis testing problem over m i.i.d.
x m with the following hypotheses: Let P x m be the empirical distribution of the samples. The optimal test, i.e., the log likelihood ratio test log(T ) = log P1(x m ) P2(x m ) can be stated in terms of information-theoretic quantities as follows: where D is the Kullback-Leibler (KL) divergence operator.
Further, using Sannov's theorem, we have the asymptotic probability of type I error: where P * 1 = argmin P ∈A c D(P ||P 1 ) and A c (T ) = {x m : D(P x m ||P 2 ) − D(P x m ||P 1 ) < 1 m log T } represents the rejection region. Similarly, the asymptotic probability of type II error is where P * 2 = argmin P ∈A D(P ||P 2 ) and A = {x m : D(P x m ||P 2 ) − D(P x m ||P 1 ) > 1 m log T } represents the acceptance region (See Figure S1). Using the Bayesian approach for hypothesis testing, the overall error probability of the log likelihood ratio test is defined as: P (m) e = αP 1 + βP 2 and the best achievable exponent in the Bayesian probability of error (a.k.a. error exponent) is defined as: Error exponent E expresses the best rate at which the error probability decays as sample size increases for a particular hypothesis testing problem. See [18] for more background information on error exponents and its related theorems.

S2.2 Estimating Error Exponents
Suppose P 1 and P 2 are sampled from the -neighborhood erence distributon P 0 , and let φ 1 , φ 2 ∈ R |X | be vectors defined as: for i = 1, 2. The following lemma express the optimal error exponent E using φ 1 and φ 2 : Lemma 1. Under the local assumption defined earlier, the best achievable error exponent of the binary hypothesis testing problem with probabilities P 1 and P 2 is: where is a constant [16].
While the above lemma characterizes the asymptotic error probability distinguishing P 1 and P 2 based on the optimal decision function, most decision functions we learn from data are not optimal, as P 1 and P 2 are unknown. Given sample data x m and an arbitrary feature function f : X → R, which could be learned from a pre-trained model, the error exponent of the decision function based on f is reduced in a way defined by the following Lemma: Lemma 2. Given a zero-mean, unit variance feature function f : X → R and i.i.d. sampled data x m , the error probability of a mismatched decision function of the form l = 1 m m i=1 (f (x (i) )) has an exponent This lemma characterizes the error probability of using a normalized feature of the input data to solve a learning task by a linear projection of this feature between the input and output domains. Note that normalizing features to zero-mean and unit variance results in an equivalent decision function with a different threshold value, thus we can apply Lemma 2 to any features without the loss of generality. Further, it's obvious that the reduced exponent E f is maximized when ξ = φ 1 − φ 2 , and the optimal value is exactly the optimal error exponent E in Lemma 1. To estimate the reduced error exponent for multi-dimensional features, we present the kdimensional generalization of Lemma 2 below: Lemma 3. Given k normalized feature functions f (x) = [f 1 (x), . . . , f k (x)], such that E[f i (X)] = 0 for all i, and cov(f (X)) = I , we define a k-d statistics of the form l k = (l 1 , ..., l k ) where l i = 1 m m l=1 f i (x (l) ). Let ξ 1 , . . . , ξ k be k vectors with entries ξ i (x) = P X (x)f i (x) , 0 ≤ i ≤ k. Then the error exponent of l k is The proof of this Lemma can be found in [12].

S2.3 H-score and Error Exponents
Now we return to the binary classification problem. Using Lemma 3, we will show the linear relationship between Hscore and error exponents.
Theorem 1. Given P X|Y =0 , P X|Y =1 ∈ N X (P 0,X ) and fea- Proof. By Lemma 3, the L.H.S. of the equation can be written =c H(f ) The last equation uses the fact cov(f (X)) = I.

S3 Experiment Details
S3.1 Experiment 4.1 Experiment Setup. The training data for the target task in this experiment consists of 20, 000 images randomly sampled from the Cifar-100 dataset [19]. It is further split 9:1 into a training set and a testing set.
We first extracted features of the Cifar-100 training images from five different layers (4a -4f) of the ResNet-50 model pretrained on ImageNet-1000 [20]. Then we computed the H-score and the empirical transfer performance of each feature function for the Cifar-100 task. To compute the empirical performance, we trained the transfer network using stochastic gradient descent with batch size 20, 000 for 100 epochs. Result Discussion. As shown in Fig. 2.a of the main paper, transfer performance is better when an upper layer of the source networks is transferred. This could be due to the inherent similarity between the target task and the source task, such that the optimal representation learned for one task can still be suitable for the other. For the experiment of selecting the best target task (Fig. 2.b), we used the same network as the former experiment to compute the empirical transfer performance with batch size 64 for 50 epochs.
In addition, we validated H-score under different target sample sizes between 5-50K. Fig. S2 shows that target sample size does not affect the relationship between H-score and logloss, which further demonstrates that the H-score computation is sample efficient.
The Taskonomy dataset [6] contains 4,000,000 images of indoor scenes collected from 600 buildings. Every image has annotations for 26 computer vision tasks. For the transferability experiment, we randomly sampled 20, 000 images as the target task training data, and selected eight supervised tasks, shown in Table S1.  [6] trained a fully supervised network with an encoder-decoder structure. When testing the transfer performance from source task T S to target task T T , the encoder output of T S is used for training the decoder of T T . For a fair comparison, we used the same trained encoders to extract source features. The output dimension of all encoders are 16 × 16 × 8 and we flattened the output into a vector of length 2048. To reduce the computational complexity, we also resized the ground truth images into 64 × 64. Label Quantization. Fig. S3 illustrates the resizing and quantization process of a pixel-to-pixel task label. During the quantization process, we are primarily concerned with two factors: computational complexity and information loss. Too much information loss will lead to bad approximation of the original problem. On the other hand, having little information loss requires larger label space (cluster size) and higher computation cost. To test the sensitivity of the cluster size, we use cluster centroids to recover the ground truth image pixel-by-pixel. The recovery results for 3D occlusion edge detection is shown in Figure S4. When the cluster size is N = 5 (right), most detected edges in the ground truth image (left) are lost. We found that N = 16 strikes a good balance between recoverability and computation cost. Comparison of H-scores and Affinities. Table S2 presents the numerical values of the transferability and affinity scores between every pair of tasks, with columns representing source tasks and rows representing target tasks. This table is in direct correspondence with the ranking matrices in Fig. 3 of the main paper. For each target task, the upper row shows our results while the lower one shows the results in [6]. Score values are included in parenteses.
Here we present some detailed results on the comparison between H-score and the affinity score in [6] for pairwise transfer. The results of transferring from all tasks to the two classification tasks (Object Class. and Scene Class.) are shown in Figure S5; The results of transferring to Depth is shown in S6. We can see in general, although affinity and transferability have totally different value ranges, they tend to agree on the order of the top few ranked tasks.  Computing Efficiency. We ran the experiment on a workstation with 3.40 GHz ×8 CPU and 16 GB memory. Each pairwise H-score computation finished in less than one hour including preprocessing.

S3.3 Experiment 4.3
Data and Tasks. The NUS-WIDE dataset [17] contains 161,789 web images for training and 107,859 images for evaluation. Its tag set consists of 81 concepts, among which we selected two subsets, shown in Table S3. One subset contains 36 common concepts including scenes, animals and objects; The other subset contains only animal concepts. The NUS-WIDE dataset provides six types of low-level features. In this   Feature Extraction and Data Preprocessing. We consider the prediction of each concept as an unbalanced binary classification task and train a 4-layer fully-connected neural network ( Fig. S7) with batch-size 2048 for 50 epochs. For an arbitrary target task, the layer 3 activation output of the source models are used to calculate the H-scores. Task Transfer Curriculum. Given n tasks T 1 , . . . , T n , first we compute the pairwise transferability matrix M ∈ R n×n using H-score, where M (i, j) = H T j (f T j ) for all 1 ≤ i, j ≤ n. We assume that the task-specific features are close to optimal, such that H Tj (f Tj ) ≈ H Tj (f Tj opt ). Then by Definition 3, M (i, j) ≈ T(T i , T j ). Using the transferability matrix, we define an undirected graph G over the tasks, where the edge weight between node i and node j is defined by Parameter α defines the threshold to filter out less related task pairs, as the transferred representation in these cases contribute very little to the training of the target task. If G is connected, the minimum spanning tree outputs a set of task pairs that maximizes the total transferability with n − 1 pairwise transfers. If G is not connected, we have a minimum spanning forest that represents several task groups that can be learned independently. Finally, we recover the transfer directions on the minimum spanning tree from the transferability matrix. For the subset with 36 common concepts in the NUS-WIDE experiment, we found that when α = 0, i.e. no edges are filtered, 33 of the 35 edges in the resulting tree indicate transfers to concept 'sky' from other concepts. This phenomenon is reasonable in that sky and other concepts coexist in images with a high probability. To demonstrate the most significant task relationships, we set edge threshold α to be the 2.3 percentile of all weights, resulting in the minimum spanning tree in Fig. 7 of the main paper. On the other hand, edge filtering is not needed for the Taskonomy tasks and the animal concepts in the NUS-WIDE experiment, since most tasks are transferable to a similar extent. Therefore we chose α = 0 in these cases.

S4 Related Works
Transfer learning. Transfer learning can be devided into two categories: domain adaptation, where knowledge transfer is achieved by making representations learned from one input domain work on a different input domain, e.g. adapt models for RGB images to infrared images [21]; and task transfer learning, where knowledge is transferred between different tasks on the same input domain [22]. Our paper focus on the latter prolem. Empirical studies on transferability.
[5] compared the transfer accuracy of features from different layers in a neural network between image classification tasks. A similar study was performed for NLP tasks by [7]. [6] determined the optimal transfer hierarchy over a collection of perceptual indoor scene understanidng tasks, while transferability was measured by a non-parameteric score called "task affinity" derived from neural network transfer losses coupled with an ordinal normalization scheme. Task relatedness. One approach to define task relatedness is based on task generation. Generalization bounds have been derived for multi-task learning [8], learning-to-learn [9] and life-long learning [10]. Although these studies show theoretical results on transferability, it is hard to infer from data whether the assumptions are satisfied. Another approach is estimating task relatedness from data, either explicitly [23,24] or implicitly as a regularization term on the network weights [25,26]. Most works in this category are limited to shallow ones in terms of the model parameters. Representation learning and evaluation. Selecting optimal features for a given task is traditionally performed via feature subset selection or feature weight learning. Subset selection chooses features with maximal relevance and minimal redundancy according to information theoretic or statistical criteria [27,28]. The feature weight approach learns the task while regularizing feature weights with sparsity constraints, which is common in multi-task learning [29,30]. In a different perspective, [13] consider the universal feature selection problem, which finds the most informative features from data when the exact inference problem is unknown. When the target task is given, the universal feature is equivalent to the minimum error probability feature used in this work.