Skip to content

Instantly share code, notes, and snippets.

@amn41
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amn41/5b52eac2e2211ab9cb57 to your computer and use it in GitHub Desktop.
Save amn41/5b52eac2e2211ab9cb57 to your computer and use it in GitHub Desktop.
%load dependenices
run('~/Software/gpml/gpml-matlab-v3.4-2013-11-11/startup.m');
% params
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
restart=true;
filename='hypers22-Jan-2015.mat';
maxiters=20;
npoints=3500;
nsparse=2000;
%load data
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
X=dlmread('descriptors.dat',' ',0,0);
ens=dlmread('energies.dat',' ',0,0);
y=ens-mean(ens);
%subsample points
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
rVec = randperm(size(y,1));
y1 = y(rVec(1:npoints),:);
X1=X(rVec(1:npoints),:);
%choose sparse inducing points
Xind=X(rVec(1:nsparse),:);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% init hypers
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if restart
load(filename,'-mat','hyp')
else
theta=0.1.*ones(size(X1,2),1);
sigma=0.1;
delta=2.0*std(y);
hyp.lik = log(sigma);
covNeighb = [theta',theta',delta,delta];
covFull = [theta',delta];
hyp.cov = log([covNeighb,covFull]');
end
init_hypers=hyp
likfunc = @likGauss;
inffunc = @infFITC;
cneighb = {'covADD',{[1,2],'covSEiso'}};
cfull={'covSEard'};
covfunc= {@covFITC,{'covSum',{cneighb,cfull}} , Xind};
%feval(covfunc{:})
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% optimise
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if maxiters > 1
hyp = minimize(hyp, @gp, -maxiters, inffunc, [], covfunc, likfunc, X1, y1);
%hyp = minimize_lbfgsb(hyp, @gp, -maxiters, @inffunc, [], cofunc, likfunc, X1, y1);
newfilename = strcat('hypers',date,'.mat');
save(newfilename,'init_hypers','hyp');
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[m s2] = gp(hyp, inffunc, [], covfunc, likfunc, X1, y1, X);
dlmwrite('gp_mtl.dat',[y m],' ');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment