Tutorials › Statistical Learning (Graduate) › Finite-Dimensional Optimization over Gram Coefficients

RKHS and Representer Theory · Tutorial 711 of 989

Finite-Dimensional Optimization over Gram Coefficients

Learn how to express RKHS fitting as optimization over kernel coefficients, calculate its Gram-matrix penalty, and evaluate predictions at new inputs.

Intermediate 10 min read

What You'll Learn

  • Express a finite-sample RKHS fit as a combination of kernel sections at the observed inputs.
  • Derive the coefficient-vector quadratic penalty from the RKHS inner product.
  • Write training predictions and new-input predictions using the Gram matrix and kernel evaluations.
  • Prove when the finite-dimensional and function-space optimization problems have the same infimum.
  • Calculate the objective and verify a stationary solution in a concrete coefficient optimization.

From Functions to Coefficients

An RKHS optimization problem appears infinite-dimensional because its decision variable is a function. For empirical risk, however, the data enter through only finitely many evaluations, \(f(x_1),\ldots,f(x_n)\). The representer theorem says that, with a norm penalty, an optimizer can be sought in the span of the kernel sections at those observed inputs. This tutorial makes that reduction explicit: it gives the coefficient objective, its Gram-matrix penalty, and the formula for predictions away from the training inputs.

Let \(\mathcal H\) be a reproducing kernel Hilbert space with kernel \(k\), and let \((x_i,y_i)\), \(i=1,\ldots,n\), be the observed data. Consider a regularized empirical risk

$$ J(f)=\frac{1}{n}\sum_{i=1}^{n}\ell(y_i,f(x_i))+\frac{\lambda}{2}\|f\|_{\mathcal H}^{2}, \qquad \lambda>0. $$

Here \(\ell(y,t)\) is the loss for response \(y\) and fitted value \(t\). The factor \(1/2\) is a convention that simplifies derivatives. Define the Gram matrix \(K\) by \(K_{ij}=k(x_i,x_j)\). Since \(k\) is a positive-semidefinite kernel, \(K\) is symmetric and positive semidefinite.

Definition: A kernel-section representation of a function in the data span is \(f_{\alpha}=\sum_{j=1}^{n}\alpha_j k(x_j,\cdot)\), where \(\alpha=(\alpha_1,\ldots,\alpha_n)^\mathsf{T}\in\mathbb R^n\). The entries of \(\alpha\) are coefficients; they are not, in general, the fitted values.

The Gram-Matrix Objective

The reproducing property gives \(f(x_i)=\langle f,k(x_i,\cdot)\rangle_{\mathcal H}\). Apply it to \(f_\alpha\): the fitted value at \(x_i\) is a sum of kernel evaluations against the coefficients. In vector form, the training predictions are \(K\alpha\).

$$ f_\alpha(x_i)=\sum_{j=1}^{n}\alpha_j k(x_i,x_j)=(K\alpha)_i, \qquad \big(f_\alpha(x_1),\ldots,f_\alpha(x_n)\big)^\mathsf{T}=K\alpha. $$

The penalty follows directly from bilinearity of the inner product. Each pair of kernel sections contributes its inner product \(k(x_i,x_j)\), so the squared RKHS norm is a quadratic form in \(\alpha\).

$$ \|f_\alpha\|_{\mathcal H}^{2} =\left\langle\sum_{i=1}^{n}\alpha_i k(x_i,\cdot), \sum_{j=1}^{n}\alpha_j k(x_j,\cdot)\right\rangle_{\mathcal H} =\sum_{i=1}^{n}\sum_{j=1}^{n}\alpha_i\alpha_j k(x_i,x_j) =\alpha^\mathsf{T}K\alpha. $$

Consequently, the coefficient form of the regularized risk is

$$ J(\alpha)=\frac{1}{n}\sum_{i=1}^{n}\ell\big(y_i,(K\alpha)_i\big) +\frac{\lambda}{2}\alpha^\mathsf{T}K\alpha. $$

This is an optimization problem over \(n\) real coefficients rather than over all functions in \(\mathcal H\). Its data-fit term depends on \(\alpha\) through \(K\alpha\); its penalty is not generally \(\alpha^\mathsf{T}\alpha\). The Gram matrix is what connects the coefficient coordinates to both predictions and RKHS geometry.

Worked Example: Computing the Penalty and Training Predictions

Suppose the Gram matrix and coefficient vector are

$$ K=\begin{pmatrix}1&1/2\\1/2&1\end{pmatrix}, \qquad \alpha=\begin{pmatrix}1\\2\end{pmatrix}. $$

First calculate the training predictions:

$$ K\alpha =\begin{pmatrix}1(1)+(1/2)(2)\\(1/2)(1)+1(2)\end{pmatrix} =\begin{pmatrix}2\\5/2\end{pmatrix}. $$

Next calculate the penalty:

$$ \|f_\alpha\|_{\mathcal H}^{2} =\alpha^\mathsf{T}K\alpha =(1,2)\begin{pmatrix}2\\5/2\end{pmatrix} =2+5=7. $$

Thus the RKHS norm is \(\sqrt{7}\). In particular, the coefficient vector \((1,2)^\mathsf{T}\) is not the vector of fitted values: that vector is \((2,5/2)^\mathsf{T}\).

Why the Finite-Dimensional Reduction Is Exact

The key fact is orthogonal projection onto the finite-dimensional subspace \(S=\operatorname{span}\{k(x_i,\cdot):i=1,\ldots,n\}\). The subspace is closed because every finite-dimensional subspace of a Hilbert space is closed, so the orthogonal projection \(P_S f\) exists for every \(f\in\mathcal H\).

Theorem: For \(\lambda>0\), the infimum of \(J(f)\) over \(f\in\mathcal H\) equals the infimum of \(J(f)\) over \(f\in S\). If a minimizer over \(\mathcal H\) exists, every such minimizer belongs to \(S\). This holds for any loss depending on \(f\) only through the observed values.

Proof. Write \(f=P_Sf+(f-P_Sf)\). The second term is orthogonal to every element of \(S\), and hence to each \(k(x_i,\cdot)\). By the reproducing property,

$$ f(x_i)-(P_Sf)(x_i) =\langle f-P_Sf,k(x_i,\cdot)\rangle_{\mathcal H}=0. $$

Therefore replacing \(f\) with \(P_Sf\) leaves every loss term unchanged. Orthogonality also gives the Pythagorean identity

$$ \|f\|_{\mathcal H}^{2} =\|P_Sf\|_{\mathcal H}^{2}+\|f-P_Sf\|_{\mathcal H}^{2} \geq \|P_Sf\|_{\mathcal H}^{2}. $$

Since \(\lambda>0\), it follows that \(J(P_Sf)\leq J(f)\). Every function in \(S\) is already in \(\mathcal H\), so restricting the search to \(S\) cannot lower the infimum; the projection inequality shows it cannot raise the infimum either. If \(f\) is a minimizer, a nonzero \(f-P_Sf\) would make the penalty strictly larger while leaving the loss unchanged. Thus \(f=P_Sf\). \(\square\)

This argument also explains why the reduction does not require the Gram matrix to be invertible. The functions in \(S\) have coefficient representations, and their predictions and norms are given by the formulas above. Questions about whether different coefficient vectors represent the same function require separate care.

Worked Example: Evaluating the Finite Objective

Use the Gram matrix and coefficients from the first example. Suppose \(n=2\), \(\lambda=1/5\), and the chosen loss has values \(2/5\) and \(11/10\) at the two fitted values \(2\) and \(5/2\), respectively. No particular loss formula is needed for this objective calculation.

The empirical loss contribution is

$$ \frac{1}{2}\left(\frac{2}{5}+\frac{11}{10}\right) =\frac{1}{2}\left(\frac{4}{10}+\frac{11}{10}\right) =\frac{3}{4}. $$

The regularization contribution is

$$ \frac{\lambda}{2}\alpha^\mathsf{T}K\alpha =\frac{1/5}{2}(7)=\frac{7}{10}. $$

So the objective at this coefficient vector is \(J(\alpha)=3/4+7/10=15/20+14/20=29/20\). This value is the objective at the stated vector; it does not, by itself, establish that the vector minimizes the objective.

Predictions at New Inputs

Once the coefficients have been chosen, evaluating the fitted function at a new input \(z\) uses its kernel evaluations with the training inputs. Define \(k_z=(k(x_1,z),\ldots,k(x_n,z))^\mathsf{T}\). The prediction is a dot product of this vector with \(\alpha\), not a new optimization problem.

$$ f_\alpha(z)=\sum_{j=1}^{n}\alpha_j k(x_j,z)=k_z^\mathsf{T}\alpha. $$

Worked Example: Predicting at a New Input

For the two-coefficient fit above, suppose a new input \(z\) has kernel evaluations \(k(x_1,z)=1/4\) and \(k(x_2,z)=3/4\). Then

$$ k_z^\mathsf{T}\alpha =\begin{pmatrix}1/4&3/4\end{pmatrix} \begin{pmatrix}1\\2\end{pmatrix} =\frac{1}{4}+\frac{6}{4} =\frac{7}{4}. $$

The prediction is \(7/4\). The training Gram matrix determines the fitted values at the observed inputs, while the kernel evaluations between \(z\) and those inputs determine the prediction at \(z\).

Optimization and a Stationarity Check

When \(\ell(y,t)\) is differentiable in \(t\), the coefficient objective has a convenient gradient. Let \(r\in\mathbb R^n\) have entries \(r_i=\partial_2\ell(y_i,(K\alpha)_i)\), where \(\partial_2\) denotes differentiation with respect to the fitted value. Symmetry of \(K\) and the chain rule give

$$ \nabla_\alpha J(\alpha)=\frac{1}{n}Kr+\lambda K\alpha. $$

Indeed, the derivative of the data-fit term is \(K^\mathsf{T}r/n=Kr/n\), and the derivative of \(\lambda\alpha^\mathsf{T}K\alpha/2\) is \(\lambda K\alpha\). A differentiable objective at an unconstrained minimum must have zero gradient. If the loss is convex in its fitted value, the objective is convex in \(\alpha\), so any stationary point is a global minimizer. The gradient equation is a useful check, but it does not by itself guarantee that a proposed point is optimal for a nonconvex loss.

Worked Example: Verifying a Convex Coefficient Optimum

Let \(n=2\), \(K=I_2\), and \(\lambda=1\). Consider the differentiable convex loss contributions \(\ell_1(t)=\exp(-2(t-1))\) and \(\ell_2(t)=\exp(2(t+1))\). The coefficient objective is

$$ J(\alpha)=\frac{1}{2}\left[\exp(-2(\alpha_1-1))+\exp(2(\alpha_2+1))\right] +\frac{1}{2}(\alpha_1^2+\alpha_2^2). $$

At \(\alpha=(1,-1)^\mathsf{T}\), the training predictions are also \((1,-1)^\mathsf{T}\). The derivatives of the two loss contributions there are \(-2\) and \(2\). Thus \(r=(-2,2)^\mathsf{T}\), and the gradient is

$$ \nabla_\alpha J =\frac{1}{2}r+\alpha =\begin{pmatrix}-1\\1\end{pmatrix} +\begin{pmatrix}1\\-1\end{pmatrix} =\begin{pmatrix}0\\0\end{pmatrix}. $$

To verify global optimality, the Hessian is

$$ \nabla_\alpha^2J(\alpha) =\begin{pmatrix}2\exp(-2(\alpha_1-1))&0\\0&2\exp(2(\alpha_2+1))\end{pmatrix}+I_2. $$

Both exponential terms are positive, so this Hessian is positive definite for every \(\alpha\). Therefore \(J\) is strictly convex, and the stationary point is its unique global minimizer. Its objective value is \(1+1=2\): the empirical loss is \(1\), and the penalty is \((1/2)(1^2+(-1)^2)=1\).

Common Pitfall and Practical Significance

A frequent error is to penalize the coefficient vector by \(\|\alpha\|_2^2\) simply because the problem has been written in coordinates. The RKHS penalty is instead \(\alpha^\mathsf{T}K\alpha\), as follows from the inner products between kernel sections. Replacing it with \(\alpha^\mathsf{T}\alpha\) generally changes the optimization problem and the fitted function. The two expressions coincide only under particular conditions on the Gram matrix.

The finite-dimensional form matters because it turns function-space fitting into a calculation involving an \(n\times n\) matrix and a vector of coefficients. It also separates two tasks cleanly: optimize using the training Gram matrix, then predict using kernel evaluations between new inputs and the training inputs. The representation is exact for norm-regularized empirical risk, not an approximation obtained by selecting a small set of basis functions.

Key takeaway: In coefficient form, the training prediction vector is \(K\alpha\), the squared RKHS norm is \(\alpha^\mathsf{T}K\alpha\), and a new-input prediction is \(k_z^\mathsf{T}\alpha\). These three expressions encode the data fit, regularization, and prediction, respectively.

Check Your Understanding

Work through these questions to check the coefficient and prediction formulas.

  1. For a kernel-section expansion \(f_\alpha=\sum_j\alpha_j k(x_j,\cdot)\), what vector gives the fitted values at the training inputs?
  2. Explain why the RKHS penalty is \(\alpha^\mathsf{T}K\alpha\), rather than automatically \(\alpha^\mathsf{T}\alpha\).
  3. State the projection argument that shows restricting to the span of the observed kernel sections does not increase the regularized empirical risk.
  4. If \(k_z=(2, -1)^\mathsf{T}\) and \(\alpha=(3,4)^\mathsf{T}\), what is the prediction at \(z\)?
  5. What additional condition on the loss makes a stationary point of the coefficient objective a global minimizer?
Clinical Biostats