Post · 17 min read· pp. 13–20

The “η-trick” reloaded: multiple kernel learning

In my previous post, I described various (potentially non-smooth) functions that have quadratic (and thus smooth) variational formulations, a possibility that I referred to as the η-trick. For example, in its simplest formulation, we have ∣w∣=min⁡η≥012w2η+12η\displaystyle |w| = \min_{ \eta \geq 0} \frac{1}{2} \frac{w^2}{\eta} + \frac{1}{2} \eta.

While it seems most often used for deriving simple optimization algorithms, it has other applications and interpretations in machine learning, in particular for “multiple kernel learning” (MKL), super-Gaussian distributions and convex relaxations of combinatorial penalties. In this post, I will cover the MKL part, which leads to a framework for learning discriminative representations from data.

We first take a detour through supervised learning with linear models based on features.

Learning “features” for “linear” predictions

Consider the typical supervised learning problem of estimating labels yi∈Ry_i \in \mathbb{R} from some inputs xix_i in a input space X\mathcal{X}, for i=1,…,ni = 1,\dots,n. The input space X\mathcal{X} is left generic on purpose, and, both in theory and practice, inputs can have a wide variety of structures (e.g., images, sequences, graphs, web pages, text documents, logs, etc.).

In order to deal with such potentially non-vectorial inputs, a feature map φ:X→Rd\varphi: \mathcal{X} \to \mathbb{R}^d is often used, and then linear models consider prediction functions of the form f(x)=w⊤φ(x)f(x) = w^\top \varphi(x), where w∈Rdw \in \mathbb{R}^d is a weight vector. The terminology “linear” refers to linearity in the parameters ww, and not linearity in the inputs xx; indeed, φ\varphi may be non-linear, and the notion can even have no meaning if X\mathcal{X} is not a vector space (note that when X=Rd\mathcal{X} = \mathbb{R}^d, and φ(x)=x\varphi(x) = x, which is common in many applications, we have in this particular situation predictions that are linear in the inputs). Given the feature map φ\varphi, the first task is to learn the parameter vector w∈Rdw \in \mathbb{R}^d.

Using the square loss for simplicity (but everything extends to convex loss functions such as the logistic loss), training is usually done by minimizing with respect to ww the so-called regularized empirical risk

12n∑i=1n(yi–w⊤φ(xi))2+λ2∥w∥22,\frac{1}{2n} \sum_{i=1}^n \big(y_i – w^\top \varphi(x_i) \big)^2 + \frac{\lambda}{2} \| w\|_2^2,
where the ℓ2\ell_2-norm-regularization is standard to avoid overfitting and makes the problem numerically well-behaved. While for general convex loss functions, we would get a convex optimization problem, here, with the square loss, it is even simpler as we can get a solution in closed form (see below).

While explicit fixed feature maps φ:X→Rd\varphi : \mathcal{X} \to \mathbb{R}^d have always been successfully used, learning these feature maps directly from data is an important task in machine learning. Given some parameterization φη(x)\varphi_\eta(x) (with parameters η\eta), one then minimizes the objective function

12n∑i=1n(yi–w⊤φη(xi))2+λ2∥w∥22,\frac{1}{2n} \sum_{i=1}^n \big(y_i – w^\top \varphi_\eta(x_i) \big)^2 + \frac{\lambda}{2} \| w \|_2^2,
both with respect to the weight vector ww and the feature parameters η\eta (the only change from the equation above is the replacement of φ(xi)\varphi(x_i) by φη(xi)\varphi_\eta(x_i)). Regardless of the particular parametrization of φη\varphi_\eta, the optimization problem is convex in ww, but typically is not convex in η\eta (and even more rarely jointly convex).

This framework includes (but is not limited to) neural networks, where ww is the set of output weights and η\eta corresponds to all other neuron weights, and φη(x)\varphi_\eta(x) is the value of the last hidden layer; see an example below.

Neural networks with two hidden layers. The input weights η\eta (in green) define a function x↦φη(x)x \mapsto \varphi_\eta(x), which is the last hidden layer (in blue), which can be linearly combined with output weights ww (in red), leading to the output yy.

The most direct approach is to estimate (η,w)(\eta,w) through joint gradient descent techniques. For neural networks, the problem is not jointly convex in (η,w)(\eta,w), but remains convex in ww; thus, even if η\eta is not optimally estimated, the optimization in ww by gradient descent, which is robust (since the objective function is convex), can still lead to a good prediction function x↦w⊤φη(x)x \mapsto w^\top \varphi_\eta(x) (in particular when the size of the feature vector dd is large). In other words (and in a quite intuitive/hand-wavy way), being very precise in the feature vector φη\varphi_\eta (which we cannot guarantee) is not as important as being precise in optimizing ww (which we can). A key empirical property of (deep) neural networks is that, with the proper initialization and stochastic gradient descent algorithms, the feature parameters η\eta can be learned with sufficient precision and great adaptivity to the final task (of predicting the labels). The theory about this now well-known empirical behavior is starting to emerge (a topic for another post).

Another approach to learn parameters, which comes with theoretical guarantees because it relies on a jointly convex problem when using appropriate parameterizations, is to first minimize with respect to ww (again, which is easy because of convexity), and optimize the resulting function with respect to the feature map φη\varphi_\eta. It turns out that there is a nice connection with kernel methods, as I now show.

Optimizing the weight vector ww and the kernel trick

We consider a generic feature map φη:X→Rd\varphi_\eta: \mathcal{X} \to \mathbb{R}^d, and we denote by Φ∈Rn×d\Phi \in \mathbb{R}^{n \times d} the concatenation of all nn feature vectors φη(xi)\varphi_\eta(x_i), i=1,…,ni=1,\dots,n (since we consider η\eta fixed in this section, we drop the dependence in η\eta). the objective writes in compact form

12n∥y–Φw∥22+λ2∥w∥22.\frac{1}{2n} \| y – \Phi w \|_2^2 + \frac{\lambda}{2} \| w\|_2^2.
Its gradient is equal to 1nΦ⊤(Φw–y)+λw\frac{1}{n} \Phi ^\top ( \Phi w – y ) + \lambda w, and setting it to zero leads to the minimizer w=(Φ⊤Φ+nλI)−1Φ⊤y∈Rdw = ( \Phi ^\top \Phi + n \lambda I)^{-1} \Phi^\top y \in \mathbb{R}^d.

We can then use the matrix inversion lemma, to obtain w=Φ⊤(ΦΦ⊤+nλI)−1yw = \Phi^\top ( \Phi \Phi ^\top + n \lambda I)^{-1} y. By doing so we went from the empirical (non-centered) covariance matrix 1nΦ⊤Φ∈Rd×d\frac{1}{n} \Phi ^\top \Phi \in \mathbb{R}^{d \times d} of the features, to the kernel matrix K=ΦΦ⊤∈Rn×nK = \Phi \Phi^\top \in \mathbb{R}^{n \times n}. The notation α=(ΦΦ⊤+nλI)−1y=(K+nλI)−1y∈Rn\alpha = ( \Phi \Phi^\top + n \lambda I)^{-1} y = ( K + n \lambda I)^{-1} y \in \mathbb{R}^n is often used, so that w=Φ⊤α=∑i=1nαiφη(xi)w = \Phi^\top \alpha = \sum_{i=1}^n \alpha_i \varphi_\eta(x_i), that is, ww is a linear combination of the input features and the weights in this combination can be computed by only accessing the input features through the kernel matrix, which is composed of dot-products φη(xi)⊤φη(xj)\varphi_\eta(x_i)^\top \varphi_\eta(x_j). This is exactly the kernel trick and (an explicit version of) the representer theorem.

The kernel trick allows to work with large feature spaces, i.e., feature maps φ\varphi with potentially high (and sometimes infinite) output dimension dd, with a computational cost which is independent of dd, if the kernel k(x,x’)=φη(x)⊤φη(x’)k(x,x’) = \varphi_\eta(x)^\top \varphi_\eta(x’) can be evaluated cheaply. Such kernels have been designed in the last twenty years for most of the common data types that I mentioned above (e.g., images, sequences, graphs, web pages, text documents, logs, etc.). See, e.g., the two reference books [1] and [2], as well as the nice teaching slides of Jean-Philippe Vert.

Note that kernel methods unfortunately come naturally with a running time with a quadratic dependence in nn (as this is the cost of computing the kernel matrix), unless specific techniques are used (Nyström / column sampling or random features) to have a running-time which is subquadratic in nn (these will be topics for future posts).

Convexity of the optimized objective

Now that we can compute the minimizer of the optimization problem above in closed form w=(Φ⊤Φ+nλI)−1Φ⊤yw = ( \Phi^\top \Phi+ n \lambda I)^{-1} \Phi^\top y, we can evaluate the optimal value of the objective

12n∥y–Φw∥22+λ2∥w∥22=12ny⊤y –1ny⊤Φw+12nw⊤(Φ⊤Φ+nλI)w.\frac{1}{2n} \| y – \Phi w \|_2^2 + \frac{\lambda}{2} \| w\|_2^2 = \frac{1}{2n} y^\top y \ – \frac{1}{n} y^\top \Phi w + \frac{1}{2n} w^\top ( \Phi^\top \Phi + n \lambda I) w .
This leads to after replacing ww by its value,
12ny⊤y –12ny⊤Φ(Φ⊤Φ+nλI)−1Φ⊤y=12ny⊤(I–Φ(Φ⊤Φ+nλI)−1Φ⊤)y.\frac{1}{2n} y^\top y \ – \frac{1}{2n} y^\top \Phi ( \Phi^\top \Phi+ n \lambda I)^{-1} \Phi^\top y = \frac{1}{2n} y^\top \big( I – \Phi ( \Phi^\top \Phi+ n \lambda I)^{-1} \Phi^\top\big) y.
Using the matrix inversion lemma again, the optimized objective is equal to
12ny⊤(I–(ΦΦ⊤+nλI)−1ΦΦ⊤)y=12ny⊤(I–(K+nλI)−1K)y=λ2y⊤(K+nλI)−1y.\frac{1}{2n} y^\top \big( I – ( \Phi \Phi^\top + n \lambda I)^{-1} \Phi \Phi^\top\big) y = \frac{1}{2n} y^\top \big( I – ( K + n \lambda I)^{-1} K \big) y = \frac{\lambda}{2} y^\top ( K + n \lambda I)^{-1} y.

The features only enter this optimal value as a function R(K)R(K) of the kernel matrix K=ΦΦ⊤∈Rn×nK = \Phi \Phi^\top \in \mathbb{R}^{n \times n}. This function happens to be convex, which can be seen here from the explicit expression of R(K)R(K) and a bit of knowledge in convex analysis (see the classical Boyd and Vandenberghe book, example 3.4). This is true beyond the square loss and this can nicely be obtained by Lagrange duality (see [3]).

As I now present, this convexity is the source of approaches to learn the kernel matrix (and hence implicitly the feature vectors) directly from data.

Multiple kernel learning (MKL)

Given that the set of kernel matrices is a convex cone, a natural parameterization is through a conic combination K(η)=∑j=1mηjKjK(\eta) = \sum_{j=1}^m \eta_j K^j of base kernel matrices K1,…,KmK^1,\dots,K^m, with η∈Rm\eta \in \mathbb{R}^m being a vector of positive weights. The typical application scenario is as follows: for a given type of data (e.g., images or biological sequences), several kernel functions k1,…,km:X×X→Rk^1,\dots,k^m : \mathcal{X} \times \mathcal{X} \to \mathbb{R} exist in the literature, based on different principles and types of information. Combining them allows to benefit from the predictive power of all of them. This framework is referred to as multiple kernel learning.

Typically, a regularization constraint on the trace of the kernel matrix K(η)K(\eta) is used as the trace of the kernel matrix is known to be a good quantity to control generalization to unseen data (see [3]); this leads to a (positive) linear constraint on the vector η\eta.

It turns out that there is a nice relationship with sparsity-inducing norms, which is obtained through the η-trick. We first reinterpret the problem as follows: we consider the feature maps φj:X→Rdj\varphi^j: \mathcal{X} \to \mathbb{R}^{d_j} associated with each kernel kjk^j, j=1,…,mj=1,\dots,m, so that Ka,bj=φj(xa)⊤φj(xb)K^j_{a,b} = \varphi^j(x_a)^\top \varphi^j(x_b) for all a,b∈1,…,na,b \in {1,\dots,n}. We can then consider the weighted concatenated feature map

φη(x)=(η11/2φ1(x),…,ηm1/2φm(x))∈Rd1+⋯+dm,\varphi_\eta(x) = ( \eta_1^{1/2} \varphi^1(x), \dots, \eta_m^{1/2} \varphi^m(x)) \in \mathbb{R}^{d_1+\dots+d_m},
for which the kernel φη(x)⊤φη(x’)\varphi_\eta(x)^\top \varphi_\eta(x’) is equal to ∑j=1mηjkj(x,x’)\sum_{j=1}^m \eta_j k^j(x,x’). See a representation below.

Multiple kernel learning with three blocks of features (in green), multiplied by the kernel parameters η1,η2,η3\eta_1,\eta_2,\eta_3 to obtain the weighted concatenated feature vector φη(x)\varphi_\eta(x) (in blue), composed of three blocks. Note that all blocks are typically multi-dimensional. These last blue blocks are linearly combined with weights ww (in red), leading to the output yy.

This provides a link between weighted sums of kernel matrices and specifically parameterized feature maps: we can indeed see the problem either as estimating a specific feature vector φη\varphi_\eta, or as estimating a conic combination of matrices. The key benefit of this formulation is that it is jointly convex in (w,η)(w,\eta), and thus provably “easy” to optimize.

The η-trick provides an interesting link with sparsity-inducing norms.

Equivalence with group Lasso

We consider as above mm block of features and we denote by Φj∈Rn×dj\Phi^j \in \mathbb{R}^{n \times d_j} the design matrix for the block j∈{1,…,m}j \in \{1,\dots,m\}. The (squared) group Lasso problem aims at estimating a linear combination of each block of variables with a regularization term that selects whole blocks (instead of individual variables regardless of the block structures if an ℓ1\ell_1-norm was used):

min⁡v1∈Rd1,…, vm∈Rdm12n∥y–Φ1v1–⋯–Φmvm∥22+λ2(∥v1∥2+⋯+∥vm∥2)2.\min_{ v_1 \in \mathbb{R}^{d_1}, \dots, \ v_m \in \mathbb{R}^{d_m}} \frac{1}{2n} \| y – \Phi^1 v_1 – \cdots – \Phi^m v_m \|_2^2 + \frac{\lambda}{2} \Big( \| v_1\|_2 + \cdots + \| v_m\|_2 \Big)^2.

We can apply the η-trick to obtain the equivalent problem:

min⁡v1∈Rd1,…, vm∈Rdmmin⁡η∈Δm12n∥y–Φ1v1–⋯–Φmvm∥22+λ2(∥v1∥22η1+⋯+∥vm∥22ηm),\min_{ v_1 \in \mathbb{R}^{d_1}, \dots, \ v_m \in \mathbb{R}^{d_m}} \min_{ \eta \in \Delta_m} \frac{1}{2n} \| y – \Phi^1 v_1 – \cdots – \Phi^m v_m \|_2^2 + \frac{\lambda}{2} \Big( \frac{\| v_1\|_2^2}{\eta_1} + \cdots + \frac{ \| v_m\|_2^2}{\eta_m} \Big),
where Δm\Delta_m is the simplex in Rm\mathbb{R}^m. Using the change of variable wj=ηj−1/2vjw_j = \eta_j^{-1/2} v_j, we exactly get the minimization of
12n∥y–Φηw∥2+λ2∥w∥22,\frac{1}{2n} \| y – \Phi_\eta {w} \|^2 + \frac{\lambda}{2} \| {w} \|_2^2,
where Φη∈Rn×(d1+⋯+dm)\Phi_\eta \in \mathbb{R}^{n \times (d_1+\cdots+d_m)} is the design matrix associated with the concatenated weighted features φη(xi)\varphi_\eta(x_i), i=1,…,ni=1,\dots,n.

Applying our results above, we can minimize with respect to w{w} in closed form as w=(Φη⊤Φη+nλI)−1Φη⊤y{w} = ( \Phi_\eta^\top \Phi_\eta + n \lambda I)^{-1} \Phi_\eta^\top y, and the resulting minimization problem in η\eta becomes

min⁡η∈Δmλ2y⊤(K(η)+nλI)−1y,\min_{\eta \in \Delta_m} \frac{\lambda}{2} y^\top \big( K(\eta) + n \lambda I \big)^{-1} y,
where K(η)=∑j=1mηjΦj(Φj)⊤∈Rn×nK(\eta) = \sum_{j=1}^m \eta_j \Phi^j (\Phi^j)^\top \in \mathbb{R}^{n \times n} is a kernel matrix which is a convex combination of the mm kernel matrices Kj=Φj(Φj)⊤K^j = \Phi^j (\Phi^j)^\top corresponding to each block of input variables.

Thus, the group Lasso is equivalent to optimizing over kernel matrices of the form K(η)K(\eta) the convex function R:K↦λ2y⊤(K+nλI)−1yR: K \mapsto \frac{\lambda}{2} y^\top ( K + n \lambda I )^{-1} y, which happens to be exactly the minimal value of the kernel ridge regression problem, that is, the regularized training error after training that we have presented above (note here that in order to have the constraint that η\eta is on the simplex, that is, η1+⋯+ηm=1\eta_1+\cdots + \eta_m = 1, we can simply impose that all kernel matrices, including K(η)K(\eta), have the same trace, which is standard in practice).

NB: This equivalence between group Lasso and MKL was first proved by Gert Lanckriet, Michael Jordan and myself [4], using convex duality and a less intuitive argument, while Alain Rakotomamonjy, Stéphane Canu, Yves Grandvalet and myself [5] used the η-trick as described above (if you know about earlier references, please let me know).

Consequences and extensions

The equivalence between MKL and group Lasso has several interesting consequences.

  • Learning weights or using uniform weights: through the η-trick, we can thus see that minimizing the regularized training error with respect to the kernel matrix is in fact the solution of a sparsity-inducing formulation. Thus it should only be used when such behavior is expected, i.e., learning from a large set of kernel matrices KjK^j, and selecting only a few of them (for theoretical guarantees, see [6]). If all kernel matrices are well-selected by the practitioner, a uniform sum typically suffices. In particular, note that for our feature weighting parametrization, the space of functions x↦w⊤φη(x)x \mapsto w^\top \varphi_\eta(x) when ww varies is always the same as soon as all components of η\eta are strictly positive, and thus using learned or uniform weights should correspond to a prior knowledge that one has about the particular set of kernel matrices.
  • Algorithms for MKL / group Lasso: Since the optimization problem is jointly convex in (w,η)(w,\eta), the global optimum can be found with arbitrary precision, with a variety of algorithms, working with kernels or not; see [7, section 1.5].

This equivalence has several interesting extensions beyond plain sparsity or group sparsity.

  • Beyond conic combinations: Other parameterizations of kernel matrices can be used, some of them related to the extension of the η-trick which I mention in my previous post. For example, when using K(Λ)=ΦΛΦ⊤K(\Lambda) = \Phi \Lambda \Phi^\top where Λ\Lambda is a symmetric positive semidefinite matrix, we obtain an equivalence with trace norm regularization [8].
  • Different constraints on η**‘s**: The trace penalty leads to a linear constraint on top of positivity. Other constraints can be used, such as ℓp\ell_p-norms for p≥1p \geq 1 [9], or constraints that induce specific behaviors on the selection of blocks of variables [7, section 3.4], e.g., block Φ1\Phi^1 always has to be selected before block Φ2\Phi^2.

Learning features or kernels?

In conclusion, we have seen two main ways of estimating data representations directly from data, which seem different: learning an explicit feature representation (often called an “embedding”) φη(x)\varphi_\eta(x) or the corresponding kernel φη(x)⊤φη(x’)\varphi_\eta(x)^\top \varphi_\eta(x’), where features are only implicit. When using these representations through linear models (which is the standard way), using one or the other makes no difference in predictive performance, but usually it does on algorithms required to learn on these features, which may need one representation or the others.

For stochastic gradient based algorithms, using explicit dd-dimensional representations leads to algorithms whose running-time complexity is proportional to ndnd, which, when dd is small, can be advantageous over the complexity in O(n2)O(n^2) associated with just computing the n×nn \times n kernel matrix. Therefore, explicit features numerically seem beneficial at first, but, specific techniques can be used (Nyström / column sampling or random features) to obtain a similar running time (again, to be explained in a future post). Thus, once appropriately done, going for features or kernels does not make a huge difference.

The parametrization of the feature vector φη(x)\varphi_\eta(x) or the associated kernel makes however a key difference. To obtain a jointly convex representation in (w,η)(w,\eta), we need a representation in terms of kernels which is linear in η\eta, which is a significant modelling limitation: only feature reweighting is possible, which is already useful in presence of many such features. However, when non-linear feature building is required, more complex parametrizations are needed. Empirically, although leading to jointly non-convex problems, they have been used efficiently and successfully in a wide variety of neural networks. Providing theoretical guarantees and guidelines on how to achieve such non-linear feature learning is an active area of research.

References

[1] Bernhard Schölkopf et Alexander Smola. Learning with kernels, MIT Press, 2002. [2] Nello Cristianini and John Shawe-Taylor. Kernel Methods for Pattern Analysis, Cambridge University Press, 2004. [3] Gert R. Lanckriet, Nello Cristianini, Peter Bartlett, Laurent El Ghaoui, and Michael I. Jordan. Learning the kernel matrix with semidefinite programming. Journal of Machine learning research, 5:27-72, 2004. [4] Francis Bach, Gert R. G. Lanckriet, Michael I. Jordan. Multiple Kernel Learning, Conic Duality, and the SMO Algorithm. Proceedings of the International Conference on Machine Learning (ICML), 2004. [5] Alain Rakotomamonjy, Francis Bach, Stéphane Canu, and Yves Grandvalet. SimpleMKL. Journal of Machine Learning Research, 9:2491-2521, 2008. [6] Francis Bach. Consistency of the group Lasso and multiple kernel learning. Journal of Machine Learning Research,  9:1179-1225, 2008. [7] Francis Bach, Rodolphe Jenatton, Julien Mairal, Guillaume Obozinski. Optimization with sparsity-inducing penalties. Foundations and Trends in Machine Learning, 4(1):1-106, 2012.  [8] Andreas Argyriou, Theodoros Evgeniou, and Massimiliano Pontil. Multi-task feature learning.Advances in Neural Information Processing Systems (NIPS), 2007. [9] Marius Kloft, Ulf Brefeld, Sören Sonnenburg, Alexander Zien. ℓp\ell_p-Norm Multiple Kernel Learning. Journal of Machine Learning Research, 12:953−997, 2011.