Commit ab7db222 authored by Jordi's avatar Jordi
Browse files

Trying FITC and PITC approx. but the toolbox is broken and it won't work.

parent 4bfd7532
Loading
Loading
Loading
Loading
+31 −8
Original line number Diff line number Diff line
% MULTIGP: test 1, using SMOS, ASCAT and AMSR2
% Test 1, using SMOS, ASCAT and AMSR2
% Test 2, trying FITC optimization => toolbox won't work with these approx.
clc, clear
rng('default'), rng(0)

@@ -15,6 +16,10 @@ modelType = 'sim'; % First order differential equation kernel (see simMeanCreat
% modelType = 'gg';  % Gaussian kernel (for convolution) and Gaussian covariance
% modelType = 'lmc'; % Linear model of corregionalization

% Full (FTC), FITC approx., PITC approx.
% FITC and PITC approx. are broken in the toolbox, they won't work
modelApprox = 'ftc';  % 'ftc', 'fitc', 'pitc'

%% Set needed paths
addpath(genpath('GPmat'))
addpath('netlab')
@@ -71,15 +76,33 @@ for n = 1:size(Y,2)

    datetick, axis tight; grid on

    if n == 1, ax1 = axis; else ax2 = axis; axis([ax1(1:2) ax2(3:4)]); end
    if n == 1, ax1 = axis; else; ax2 = axis; axis([ax1(1:2) ax2(3:4)]); end
    title(ylabels{n})
    hold off
end

%% Options for multiGP model

% Common options
options = multigpOptions('ftc');
% MultiGP options
options = multigpOptions(modelApprox);
switch modelApprox
case {'fitc', 'pitc'}
    % initialInducingPositionMethod options
    % kmeansIsotopic, kmeansHeterotopic, espaced, espacedInRange, fixIndices
    % randomComplete, randomDataIsotopic, nonrandomDataIsotopic, randomDataHeterotopic
    options.initialInducingPositionMethod = 'randomDataIsotopic';
    options.numActive = 30;
    % Choose inducing points as a % of samples
    % options.numActive = fix(length(utc_ref) * 0.02);
    options.beta = 1e-1;
    options.fixInducing = false;
    options.kern.nout = size(Ytrain, 2);
end
% Other options I didn't tried
% options.kern.isArd = 0;
% options.includeNoise = false;

% The optimiser
options.optimiser = 'scg';

% Specific options
@@ -113,11 +136,11 @@ end
mdate = datestr(now, 'yyyymmdd_hhMM');
switch lower(modelType)
    case {'sim', 'gg'}
        fname = sprintf('SMOS_model_%s_site_%s_nlf_%d_sensors_%d_%s.mat', ...
            upper(modelType), site, options.nlf, sensors, mdate);
        fname = sprintf('SMOS_model_%s_%s_site_%s_nlf_%d_sensors_%d_%s.mat', ...
            upper(modelType), upper(modelApprox), site, options.nlf, sensors, mdate);
    case 'lmc'
        fname = sprintf('SMOS_model_%s_site_%s_nlf_%d_rank_%d_sensors_%d_%s.mat', ...
            upper(modelType), site, options.nlf, model.rankCorregMatrix, sensors, mdate);
        fname = sprintf('SMOS_model_%s_%s_site_%s_nlf_%d_rank_%d_sensors_%d_%s.mat', ...
            upper(modelType), upper(modelApprox), site, options.nlf, model.rankCorregMatrix, sensors, mdate);
end
rname = strrep(fname, '_model_', '_results_');
fname = ['models/' fname];
+25 −17
Original line number Diff line number Diff line
function model = trainLFMGP(Xtrain, Ytrain, options)

q = 1; % Input dimension
d = size(Ytrain, 2) + options.nlf;

X = cell(size(Ytrain, 2) + options.nlf, 1);
Y = cell(size(Ytrain, 2) + options.nlf, 1);

switch options.approx
case {'fitc', 'pitc', 'dtc', 'dtcvar'}
    % Do not include LFs with these approximations, the toolbox already
    % includes them.
    disp('Not including empty LFs')
    X = Xtrain';
    Y = Ytrain';
otherwise
    disp('Including empty LFs')
    % When we want to include the structure of the latent force kernel within
    % the whole kernel structure, and we don't have access to any data from the
    % latent force, we just put zeros in the vector X and empty in the vector y.

    X = cell(size(Ytrain, 2) + options.nlf, 1);
    Y = cell(size(Ytrain, 2) + options.nlf, 1);
    for j = 1:options.nlf
        Y{j} = [];
        X{j} = zeros(1, q);
@@ -18,6 +22,10 @@ for i = 1:size(Ytrain, 2)
        Y{i+options.nlf} = Ytrain{i};
        X{i+options.nlf} = Xtrain{i};
    end
end

q = 1; % Input dimension
d = size(Ytrain, 2); % Outputs

% Creates the model
warning('off', 'multiKernParamInit:noCrossKernel')