Skip to content

Commit ec3dff6

Browse files
committed
small changes
1 parent 637e38a commit ec3dff6

File tree

2 files changed

+40
-10
lines changed

2 files changed

+40
-10
lines changed

sp_covMTL.m

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,38 @@
1-
function K = sp_covMTL(cov, M, hyp, x, z, i)
1+
function K = sp_covMTL(cov, param, hyp, x, z, i)
22

33
% MTL covariance function
44
%
55
% usage:
66
% sp_covMTL('init', number_of_hyperparameters);
7-
% sp_covMTL('initte', task_indicator_test);
8-
% sp_covMTL(input_covariance_function, task_indicator, ...);
7+
% sp_covMTL(input_covariance_function, task_indicator(s), ...);
98
%
10-
% takes a vector of hyperparameters:
9+
% the task indicators can be specified either as matrix M (training) or as
10+
% a cell array {Mtr, Mte} (testing)
11+
%
12+
% this function requires a vector of hyperparameters:
1113
% hyp = [ ell; covp ]
14+
%
1215
% where ell is the lower diagonal of L = chol(Kf)' and covp is a vector of
13-
% parameters for the input covariance functions
16+
% parameters for the input covariance function (Kx)
1417
%
1518
%_________________________________________________________________________
1619
% Copyright (C) A Marquand
1720

1821
if nargin<2, error('Not enough parameters provided.'), end
1922

2023
persistent Nhyp;
21-
persistent Mte;
24+
%persistent Mte;
2225

23-
if strcmp(cov,'init'), Nhyp = M; return; end
24-
if strcmp(cov,'inittest'), Mte = M; return; end
26+
if strcmp(cov,'init'), Nhyp = param; return; end
27+
%if strcmp(cov,'inittest'), Mte = M; return; end
2528
if isempty(Nhyp), error('Covariance function not initialised.'); end
2629

30+
if iscell(param)
31+
M = param{1};
32+
else
33+
M = param;
34+
end
35+
2736
if nargin<4, K = num2str(Nhyp); return; end % report number of parameters
2837
if nargin<5, z = []; end % make sure, z exists
2938
xeqz = numel(z)==0;
@@ -41,6 +50,11 @@
4150

4251
% configure input kernel from input arguments
4352
if dg % kss
53+
if iscell(param) && length(param) == 2
54+
Mte = param{2};
55+
else
56+
error('for diag mode, a cell array {M, Mtr} is required.');
57+
end
4458
Kx = feval(cov{:}, hyp((lmaxi+1):end), x);
4559
%K = (M*Kf*M').*Kx;
4660
K = (Mte*Kf*Mte').*Kx;
@@ -51,8 +65,10 @@
5165
Kx = dokron(Kx,M);
5266
K = (M*Kf*M').*Kx;
5367
else % Ks
54-
if isempty(Mte)
55-
error('Covariance function not initialized for testing');
68+
if iscell(param) && length(param) == 2
69+
Mte = param{2};
70+
else
71+
error('for prediction, a cell array {M, Mtr} is required.');
5672
end
5773
Kx = feval(cov{:}, hyp((lmaxi+1):end), x, z);
5874
%K = (Mte*Kf*M').*Kx;

sp_qsub_cleanup.m

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
function fstem = sp_qsub_cleanup
2+
3+
user = getenv('USER');
4+
pid = feature('getpid');
5+
[~,host] = system('hostname -s');
6+
host = strtrim(host);
7+
host = regexprep(host,'-','_');
8+
fstem = [user,'_',host,'_p',num2str(pid)];
9+
10+
11+
fprintf('Cleaning up... ');
12+
system(['rm -f ',fstem,'*']);
13+
fprintf('done.\n');
14+
end

0 commit comments

Comments
 (0)