-
Notifications
You must be signed in to change notification settings - Fork 3
/
dlsmiy_cont.m
executable file
·89 lines (70 loc) · 2.17 KB
/
dlsmiy_cont.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
function [Wh,f,infoLog] = dlsmiy_cont(X, Y, options)
%
% Continuous case.
%
[m n] = size(X);
if nargin < 3
options = [];
end
% Normalize both X and Y
X = normdata(X);
Y = normdata(Y);
% Process options
options = processDLSMIoptions(X,Y, options);
v = options.v;
sigmayfactor_list = options.sigmayfactor_list;
seed = options.seed;
b = options.b;
nzthreshold = options.nzthreshold;
threshold = options.threshold;
% Initializer of W
W0 = myProcessOptions(options, 'W0', randInit(m,seed) );
% Set the RandStream to use the seed
oldRs = RandStream.getDefaultStream();
rs = RandStream.create('mt19937ar','seed',seed);
RandStream.setDefaultStream(rs);
% Basis centers
kmeanscenters = myProcessOptions(options, 'kmeanscenters', false);
if kmeanscenters
[Xc, Yc] = kmeansCenters( X, Y, b, seed);
else
rand_index = randperm(n);
Xc = X(:, rand_index(1:b));
Yc = Y(:, rand_index(1:b));
end
%%% Begin DLSMI %%%%%
% Calculate constants (put them in const struct)
const.Xc = Xc;
const.Yc = Yc;
% Gaussian kernel on Y
medy = meddistance(Y);
% Cell array of Ky's
Kys = arrayfun(@(sig)(kerGaussian(Yc, Y, sig)), ...
medy*sigmayfactor_list, 'UniformOutput', false);
const.Kys = Kys;
const.medy = medy;
funObj = @(Wx, refInfo)(funObjNegLSMIy_cont(Wx, X, Y, const, options, refInfo));
% Options for optimizer
opt.optTol = options.optTol;
opt.progTol = options.progTol;
opt.maxIter = options.maxIter;
opt.order = options.order;
opt.nzthreshold = nzthreshold;
opt.threshold = threshold;
refInfo = Ref();
[Wh, fEvals, f] = L1GeneralProjection_nuke(funObj,W0,v*ones(m,1), opt, refInfo);
% [Wh] = L1General2_OPG(funObj,W0, v*ones(m,1) , options);
% [Wh, f] = L1General2_TMP(funObj,W0, v*ones(m,1) , opt);
% [Wh] = L1General2_BBSG(funObj,W0, v*ones(m,1) , options);
% [Wh] = L1General2_DSST(funObj,W0, v*ones(m,1) , options);
% [Wh] = L1General2_PSSas(funObj,W0, v*ones(m,1), opt);
% [Wh] = L1General2_AS(funObj,W0, v*ones(m,1) , options);
infoLog = refInfo.obj;
infoLog.G = [infoLog.G{:}];
infoLog.F = [infoLog.F{:}];
infoLog.W = [infoLog.W{:}];
infoLog.T = [infoLog.T{:}];
% Set RandStream back to its original one
RandStream.setDefaultStream(oldRs);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
end