-
Notifications
You must be signed in to change notification settings - Fork 0
/
LAE.m
66 lines (61 loc) · 1.44 KB
/
LAE.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
function z = LAE(x,U,cn)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% LAE (Local Anchor Embedding)
% Written by Wei Liu ([email protected])
% x(dX1): input data vector
% U(dXs): anchor data matrix, s: the number of closest anchors
% cn: the number of iterations, 5-20
% z: the s-dimensional coefficient vector
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[d,s] = size(U);
z0 = ones(s,1)/s; %(U'*U+1e-6*eye(s))\(U'*x); % % %
z1 = z0;
delta = zeros(1,cn+2);
delta(1) = 0;
delta(2) = 1;
beta = zeros(1,cn+1);
beta(1) = 1;
for t = 1:cn
alpha = (delta(t)-1)/delta(t+1);
v = z1+alpha*(z1-z0); %% probe point
dif = x-U*v;
gv = dif'*dif/2;
clear dif;
dgv = U'*U*v-U'*x;
%% seek beta
for j = 0:100
b = 2^j*beta(t);
z = SimplexPr(v-dgv/b);
dif = x-U*z;
gz = dif'*dif/2;
clear dif;
dif = z-v;
gvz = gv+dgv'*dif+b*dif'*dif/2;
clear dif;
if gz <= gvz
beta(t+1) = b;
z0 = z1;
z1 = z;
break;
end
end
if beta(t+1) == 0
beta(t+1) = b;
z0 = z1;
z1 = z;
end
clear z;
clear dgv;
delta(t+2) = ( 1+sqrt(1+4*delta(t+1)^2) )/2;
%[t,z1']
if sum(abs(z1-z0)) <= 1e-4
break;
end
end
z = z1;
clear z0;
clear z1;
clear delta;
clear beta;