Home

Awesome

FALKON_paper

:grey_exclamation:NOTE:grey_exclamation:: A new and improved version of the Falkon algorithm is now available at (https://github.com/FalkonML/falkon):

Intro

This repository provides the code used to run the experiments of the paper "FALKON: An Optimal Large Scale Kernel Method" (https://arxiv.org/abs/1705.10958). In particular, the folder FALKON contains a preliminary MATLAB implementation of the algorithm, that uses CPU and one GPU.

Installation on LINUX

To install the code, set the MATLAB shell path to the FALKON folder and run:

mex -largeArrayDims ./tri_solve_d.cpp -lmwblas -lmwlapack
mex -largeArrayDims ./inplace_chol.cpp -lmwblas -lmwlapack

Furthermore the "free" command line linux tool needs to be installed on your machine.

FALKON

The algorithm is implemented by the function

alpha = falkon(Xtr, C, kernel, Ytr, lambda, T, cobj, callback, memToUse, useGPU)

Input:

Output:

Example:

In this example we assume to have already loaded and preprocessed Xtr, Ytr (training set) and Xts, Yts (test set), the following script executes FALKON, for 10 iterations, with a Gaussian kernel of width 15, a lambda=0.001, 10,000 Nystrom centers. Note that in the following code 1) FALKON is not using any support object and callback, 2) the GPU will be used for the computations and 3) the function will use all the free memory available on the machine (depending on the dimensionality of the problem).

addpath(genpath('../'));

% kernel to use
sigma = 15;
kernel = gaussianKernel(sigma);

% regularization parameter lambda
lambda = 1e-3;

% number of Nystrom centers
m = 10000;

% matrix of the Nystrom centers from the training set
ntr = size(Xtr,1);
trp = randperm(ntr,m);
C = Xtr(trp,:);

%number of iterations
T = 10;

% empty object
cobj = [];

% empty callback
callback = @(alpha, cobj) [];

% GB of memory to use (using "[]" will allow the machine to use all the free memory)
memToUse = [];

% flag for using or not the GPU
useGPU = 1;

alpha = falkon(Xtr , C , kernel, Ytr, lambda, T, cobj, callback, memToUse, useGPU);

To test the predictor learned above on the test set Xts, Yts, we compute the mean square error (MSE) with the help of the function KtsProd (that computes Ypred = kernel(Xts, C) in blocks), as follows


% prediction values on the test set Xts
Ypred = KtsProd(Xts, C, alpha, 10, kernel);

% mean square error
MSE = mean((Yts - Ypred).^2)

Experiments

The scripts to reproduce the experiments of the paper are in the folder "Experiments". Each script performs supervised learning on a specific dataset. In particular the script assumes that the dataset has been already preprocessed and the resulting features saved on disk in ".mat" format, for more details see the comments in the code of each script.

Example:

To run FALKON on the MillionSongs dataset with the same setting presented in the table of the paper (10,000 Nystrom centers):