-
Notifications
You must be signed in to change notification settings - Fork 1
/
UpdateLincomb_GD_kernel.m
86 lines (66 loc) · 1.48 KB
/
UpdateLincomb_GD_kernel.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
function [A] = UpdateLincomb_GD_kernel(A,K,S,para,Obs)
% function solve min C1\sum_m \|Km-AmKmAm\|+ C2\|AmKmAm -\sum_lSlAlKlAl\|^2 + C3 \|A\|2_1
% A(i,:,m) : linear component for i th point in m th view
%
% Input:
%
M=size(A,3);
for m=1:1:M
[A,rtime(m),iteration(m)] = GD_kernel(A,K,S,m,para,Obs);
end
end
function [Anew,spT,counter]=GD_kernel(A,K,S,m,para,Obs)
alpha=1E-10;
beta=0.2;
eps=1E-6;
sigma = alpha;
Acur=A;
fcur=fkernel(Acur,K,S,para,Obs);
counter=1;
diff=10;
tstart=tic;
check=0;
while(diff>eps )
fold=fcur;
Aold=Acur;
g=gkernel(A,K,S,m,para,Obs);
descent=g;
[Acur,fcur]=getStepSize2(Aold,descent,g,K,S,m,para,sigma,beta,Obs);
counter=counter+1;
if (counter >10000 )
Anew=Aold;
spT= toc(tstart);
return;
end
end
Anew=Aold;
spT= toc(tstart);
end
function [Anew,fnew]=getStepSize2(Aold,descent,g,K,S,m,para,sigma,beta,Obs)
step=1000;
FLAG=1;
count=0;
fcur=fkernel(Aold,K,S,para,Obs);
gs=sigma*norm(g'*descent);
while(FLAG)
count=count+1;
temp=ProxL21(squeeze(Aold(:,:,m)-step*descent),para,step,size(Aold,3));
Anew=Aold;
Anew(:,Obs(m).id,m)=temp(:,Obs(m).id);
unobs=setdiff([1:1:size(Aold,1)],Obs(m).id);
Anew(:,unobs,m)=0;
fnew =fkernel(Anew,K,S,para,Obs) ;
if( fnew.T > fcur.T - 0.01*step*gs)
step=beta*step;
beta=beta*0.9;
else
return;
end
if norm(step*descent)<1E-18
Anew=Aold;
fnew=fcur;
step=0;
return;
end
end
end