-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMKCemdbht.m
113 lines (96 loc) · 2.7 KB
/
MKCemdbht.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
function [PredK,A,S,obj,iOutput] = MKCemdbht(K,MID,para,init)
% this solve MKCembdht formulation
%
% input :
% K: kernels matrix size N x N x M. K(n1,n2,m) =kenrel values among n1 and n2 datapoints in m view
% MID: a matrix of NxM {0,1} matrix where MID(n,m) = 1 indicates nth data is known in mth view
% para: contain usedefined parameters para.c1 Withinviewloss + para.c2 betweenviewloss + para.c3 L21norm regularisation
%
%init : if init =1 then A^{(m)} is initialized by non diagonal selfrepresentative matrix of K^{(m)}
% otherwise it A^{(m)} is randomly initalized
%
%Output:
% PredK =\hat(K) : predicted kernel matrices of size NxNxM
% A : learnt reconstruction matrix
% S : Inter-view similarity matrix
% objective values
% iOutput : intermediate objective function
% (c) Sahely Bhadra
%
% Algorithm is explained as in the linked document
% http://arxiv.org/abs/1602.02518
%
% Jun. 1, 2016.
tstart=tic;
M=size(K,3);
N=size(K,2);
diff= 10;
eps=1E-5;
for m=1:1:M
Obs(m).id=find(MID(:,m)==1);
end
% initialization
if init==1
S=ones(M,M);
S=S-diag(diag(S));
for m=1:1:M
S(m,:)=ProjSimplex(S(m,:));
end
S=S-diag(diag(S));
else
S=randn(M,M);
S=S-diag(diag(S));
for m=1:1:M
S(m,:)=ProjSimplex(S(m,:));
end
S=S-diag(diag(S));
end
for m=1:1:M
if init==1
A(:,:,m)=zeros(size(K(:,:,m)));
A(:,Obs(m).id,m)=randn(N,length(Obs(m).id));
A(Obs(m).id,Obs(m).id,m)=RelevantViews(K(Obs(m).id,Obs(m).id,m));
else
A(:,:,m)=zeros(size(K(:,:,m)));
A(:,Obs(m).id,m)=randn(N,length(Obs(m).id));
end
end
fcur=femdbht(A,K,S,para,Obs);
iteration=0;
% parametes are optimized by block wise decsend
while(diff>eps)
Sold=S;
Aold=A;
fold=fcur;
iteration=iteration+1;
iOutput.intermediate(iteration).f=fold; % stoer objecttive function value in each iteration
iOutput.iteration=iteration;
%updating A
A = UpdateLincomb_GD_emdbht(Aold,K,Sold,para,Obs);
for m=1:1:M
L(m,:)=reshape(A(:,:,m),1,numel(A(:,:,m)));
end
S=RelevantViews(L);
fcur=femdbht(A,K,S,para,Obs)
iteration =iteration +1
diff=(fold.T-fcur.T)/norm(abs(fcur.T)+abs(fold.T))
if (iteration >10000 )
A=Aold;
S=Sold;
obj=femdbht(A,K,S,para,Obs);
spT= toc(tstart);
for m=1:1:M
PredK(:,:,m)=squeeze(A(:,:,m))*squeeze(K(:,:,m))*squeeze(A(:,:,m))';
end
return;
end
end
A=Aold;
S=Sold;
obj=femdbht(A,K,S,para,Obs);
spT= toc(tstart);
for m=1:1:M
PredK(:,:,m)=squeeze(A(:,:,m))*squeeze(K(:,:,m))*squeeze(A(:,:,m))';
end
end