-
Notifications
You must be signed in to change notification settings - Fork 3
/
undlsmi_dis.m
executable file
·62 lines (47 loc) · 1.46 KB
/
undlsmi_dis.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
function [Wh,f] = undlsmi_dis(X, Y, options)
%
% Unconstrained DLSMI for discrete output.
% L1-norm must be approximated so that derivative can be calculated.
%
[m n] = size(X);
if nargin < 3
options = [];
end
% Normalize X
X = normdata(X);
% Process options
options = processDLSMIoptions(X,Y, options);
v = options.v;
fold = options.fold;
sigmazfactor_list = options.sigmazfactor_list;
lsmilambda_list = options.lsmilambda_list;
seed = options.seed;
b = options.b;
winitfunc = options.winitfunc;
% wpenaltyfunc = penalty function for W (typically an approximation of l1)
wpenaltyfunc = myProcessOptions(options, 'wpenaltyfunc', @(w)(l1approx(w,1e-10)));
options.wpenaltyfunc = wpenaltyfunc;
% Set the RandStream to use the seed
oldRs = RandStream.getDefaultStream();
rs = RandStream.create('mt19937ar','seed',seed);
RandStream.setDefaultStream(rs);
% Basis centers
rand_index = randperm(n);
Xc = X(:, rand_index(1:b));
Yc = Y(:, rand_index(1:b));
%%% Begin DLSMI %%%%%
% Calculate constants (put them in const struct)
const.Xc = Xc;
const.Yc = Yc;
const.Ky = kerDelta(Yc, Y);
fun = @(Wx)(funObjNegLSMI_dis(Wx, X, Y, const, options));
funObj = @(Wx)(augmentPenalty(Wx, fun, v, wpenaltyfunc));
% Pick one optimizer without reasons ...
W0 = winitfunc(m);
% Options for optimizer
opt = lbfgsOptions();
[Wh,f] = fminlbfgs(funObj, W0, opt);
% Set RandStream back to its original one
RandStream.setDefaultStream(oldRs);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
end