\documentclass[11pt]{article}
\usepackage{latexsym}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{epsfig}
\usepackage[tight]{subfigure}

\newcommand{\handout}[5]{
  \noindent
  \begin{center}
  \framebox{
    \vbox{
      \hbox to 5.78in { {#1} \hfill #2 }
      \vspace{4mm}
      \hbox to 5.78in { {\Large \hfill #5  \hfill} }
      \vspace{2mm}
      \hbox to 5.78in { {\em #3 \hfill #4} }
    }
  }
  \end{center}
  \vspace*{4mm}
}

\newcommand{\lecture}[5]{\handout{#1}{#2}{#3}{#4}{#5}}

\newtheorem{theorem}{Theorem}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{observation}[theorem]{Observation}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{claim}[theorem]{Claim}
\newtheorem{fact}[theorem]{Fact}
\newtheorem{assumption}[theorem]{Assumption}

% 1-inch margins, from fullpage.sty by H.Partl, Version 2, Dec. 15, 1988.
\topmargin 0pt
\advance \topmargin by -\headheight
\advance \topmargin by -\headsep
\textheight 8.9in
\oddsidemargin 0pt
\evensidemargin \oddsidemargin
\marginparwidth 0.5in
\textwidth 6.5in

\parindent 0in
\parskip 1.5ex
%\renewcommand{\baselinestretch}{1.25}

\begin{document}

\lecture{Statistical Techniques in Robotics (16-831, F08)}{Lecture \#23 (Nov 11, 2008)}{Lecturer: Drew Bagnell}{Scribe: Daniel Munoz}{Kernel Methods / Functional Gradient Descent}

\section{Goal}
The high-level idea is to learn non-linear models using the same
gradient-based approach used to learn linear models.
Hopefully this will result in better models that improve classification.

\section{Review}
\begin{itemize}
\item
Ultimately, we wish to learn a function $f: \mathbb{R}^n \rightarrow \mathbb{R}$ that assigns
a meaningful score given a data point.  E.g. in binary classification, we would like $f(\cdot)$ 
to return positive and negative values, given positive and negative samples, respectively.

\item
A kernel $K: \mathbb{R}^n \times \mathbb{R}^n \rightarrow \mathbb{R}$ 
intuitively measures the \textit{correlation} between $f(\mathbf{x_i})$ and $f(\mathbf{x_j})$.  Considering
a matrix $\mathbf{K}$ with entries $K_{ij} = K(\mathbf{x_i}, \mathbf{x_j})$, then matrix 
$\mathbf{K}$ must satisfy the properties:
\begin{itemize}
	\item
	$\mathbf{K}$ is symmetric ($K_{ij} = K_{ji}$)
	\item
	$\mathbf{K}$ is positive-definite 
		($\forall \mathbf{x} \in \mathbb{R}^n : \mathbf{x} \neq \mathbf{0}, \mathbf{x^T K x} > 0$)
\end{itemize}
Hence, a valid kernel is the inner product: $K_{ij} = \langle\mathbf{x_i, x_j}\rangle$.  

\item
A function can be considers as a weighted composition of many kernels 
centered at various locations $\mathbf{x_i}$:
\begin{equation}
  \label{eq:rkhs-function}
	f(\cdot) = \sum_{i=1}^Q \alpha_i K(\mathbf{x_i}, \cdot),
\end{equation}
where $Q$ is the number of kernels that compose $f(\cdot)$ and $\alpha_i \in \mathbb{R}$ is
each kernel's associated weight.
\begin{itemize}
	\item
	All functions $f(\cdot)$ with kernel $K$ that satisfy the above properties and can be written in the
	form of Equation \ref{eq:rkhs-function} are said to lie in a
	\textit{Reproducing Kernel Hilbert Space} (RKHS) $\mathcal{H}_K$: $f \in \mathcal{H}_K$
	
	\item The inner-product of two functions $f$ and $g$ is defined as
	\begin{equation}
		\langle f,g \rangle = \sum_{i=1}^Q \sum_{j=1}^P \alpha_i \beta_j K(\mathbf{x_i, x_j}) = \mathbf{\alpha^T K \beta},
	\end{equation}
	where $\mathbf{\alpha} \in \mathbb{R}^Q$ and $\mathbf{\beta} \in \mathbb{R}^P$ are the
	kernel coefficients for $f$ and $g$, respectively.
	\begin{itemize}
		\item By definition, the following property holds: $\langle K(\mathbf{x_i}, \cdot), K(\cdot, \mathbf{x_j})\rangle = K(\mathbf{x_i,x_j})$ 
		  	    
	 	\item The reproducing property is observed by taking the inner-product of a function with a kernel:
	 				$\langle f, K(\mathbf{x_j}, \cdot)\rangle = \langle \sum_{i=1}^Q \alpha_i K(\mathbf{x_i},\cdot) , K(\cdot, \mathbf{x_j})\rangle
	 				= \sum_{i=1}^Q \alpha_i \langle K(\mathbf{x_i}, \cdot), K(\cdot, \mathbf{x_j})\rangle
	 				= \sum_{i=1}^Q \alpha_i  K(\mathbf{x_i}, \mathbf{x_j}) = f(\mathbf{x_j})$
	 				
		\item Note that due to positive-definite constraint, the squared norm of a function $f$ is always positive
	  	    when $\mathbf{\alpha \neq 0}$. ($||f||^2 = \langle f,f\rangle = \mathbf{\alpha^T K \alpha} > 0$)

	\end{itemize}
\end{itemize}

%%%%%%%%%%%%
\item 
A \textit{functional} $F : f \rightarrow \mathbb{R}$ is a function of functions $f \in \mathcal{H}_K$.
Examples:
	\begin{itemize}
		\item
			$F[f] = ||f||^2$
		\item
			$F[f] = (f(x) - y)^2$
		\item
			$F[f] = \frac{\lambda}{2} ||f||^2 + \sum_i (f(x_i) - y_i)^2$ 
	\end{itemize}

%%%%%%%%%%%%%
\item
A functional gradient $\nabla F[f]$ is defined implictly
as the linear term of the change in a function due to a small
perturbation $\epsilon$ in its input: $F[f + \epsilon g] = F[f] + \epsilon \langle \nabla F[f], g \rangle + O(\epsilon^2)$
	\begin{itemize}
		\item Example: $\nabla F[f] = \nabla ||f||^2 = 2f$
		\begin{eqnarray*}
			F[f + \epsilon g] & = &\langle f + \epsilon g, f + \epsilon g\rangle \\
			& = & ||f|| + 2 \langle f, \epsilon g \rangle + \epsilon^ 2	||g|| \\
			& = & ||f|| + \epsilon \langle 2f , g \rangle + O(\epsilon^2)
		\end{eqnarray*}
	\end{itemize}
\end{itemize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{More functional gradients}
\begin{itemize}
\item
Consider \textit{differentiable} functions $C : \mathbb{R} \rightarrow \mathbb{R}$ that are functions 
of functionals $G$, $C(G[f])$.  We will be minimizing these (cost) functions 
in the near future.

\item
The derivative of these functions follows the chain rule: $\nabla C(G[f]) = C'(G[f]) \nabla G[f]$
	\begin{itemize}
		\item
		Example: If $C = (||f||^2)^2$, then $\nabla C = (2(||f||^2))(2f)$
	\end{itemize}
	
\item
The evaluation functional evaluates $f$ at the specified $x$: $F_x[f] = f(x) = e_x[f]$
	\begin{itemize}
		\item
		Its gradient is $\nabla e_x = K(x, \cdot)$
		\begin{eqnarray*}
			e_x[f + \epsilon g] &=& f(x) + \epsilon g(x) + 0 \\
			& = & f(x) + \epsilon \langle K(x, \cdot) , g \rangle + 0 \\
			& = & e_x[f] + \epsilon \langle \nabla e_x , g \rangle + O(\epsilon^2)
		\end{eqnarray*}
		
		\item
		Called a \textit{linear functional} due to lack of multiplier on perturbation $\epsilon$
	\end{itemize}
\end{itemize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Functional gradient descent}
\begin{itemize}
\item
Consider the regularized least squares loss function $L[f]$
\begin{eqnarray*}
L[f] &=& (f(x_i) - y_i)^2 + \lambda ||f||^2 \\
\nabla L[f] &=& 2(f(x_i) - y_i)K(x_i, \cdot) + 2 \lambda f
\end{eqnarray*}

\item 
Update rule:
\begin{eqnarray*}
f^{t+1} & \leftarrow & f^t - \eta_t \nabla L \\
& \leftarrow & f^t - \eta_t (2(f^t(x_i) - y_i)K(x_i, \cdot) + 2 \lambda f^t) \\
& \leftarrow & f^t(1 - 2 \eta_t \lambda) - \eta_t (2(f^t(x_i) - y_i)K(x_i, \cdot))
\end{eqnarray*}

\item
Need to perform $O(T)$ work at each time step

\item
Example: Figure \ref{fig:kernel_update} shows an update over 3 points $\{(x_1,+), (x_2,-) , (x_3,+)\}$.  
The individual kernels centered at the points are \textbf{independently} drawn 
with colored lines.  After 3 updates, the function $f$ looks like the solid black line.
\begin{figure}[ht]
\centering
\includegraphics[width=0.85\linewidth]{kernel_update}
\label{fig:kernel_update}
\caption{Illustration of function after 3 updates}
\end{figure}

\item
\textbf{Representer Theorem} (informally): Given a loss function and regularizer objective 
with many data points $\{x_i\}$, the minimizing solution $f^*$ can be represented as
\begin{equation}
f^*(\cdot) = \sum_i \alpha_i K(x_i, \cdot)
\end{equation}

\item
Alternate idea from class: perform gradient descent in the space of $\alpha$ coefficients: $\nabla_{\alpha} L$
	\begin{itemize}
	\item Takes $n^2$ iterations to get same performance ($n$ = number of iterations of functional gradient descent)
	\item Every iteration is $O(T^2)$
	\end{itemize}

\end{itemize}

\section{Kernel SVM}
\begin{itemize}
\item
General loss function: $L[f] = \frac{\lambda}{2}||f||^2 + C_t(F_{x_i}[f])$
\item
General update rule: $f_{t+1} \leftarrow f_t(1 - \lambda \eta_t) - \eta_t C_t'(F_{x_i}[f]) K(x_i, \cdot)$
\item
SVM cost function: $C_t(F_{x_i}) = \max(0, 1-f(x_i)y_i)$
\end{itemize}
\begin{equation}
\nabla C_t = 
	\begin{cases}
	0 &,  1 - y_i f(x_i) \leq 0 \\
	(C'(F_{x_i}[f])) (\nabla F_{x_i}[f])  = (-y_i) (K(x_i, \cdot)) & ,  \text{otherwise}
	\end{cases}
\end{equation}
\end{document}
