-
Notifications
You must be signed in to change notification settings - Fork 8
/
obj_MVCC.m
63 lines (63 loc) · 1.82 KB
/
obj_MVCC.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
function [y,acc, nmi, Pu, P, R, F, AR,OBJ] = obj_MVCC(W,num_views,numClust,beta,truth,numiter)
if (min(truth)==0),truth = truth + 1;end
N = size(W,1);
opts.disp = 0;
U = zeros(N,numClust,num_views);
gamma = 1;
S(1:N,1:N) = 0;
for v =1:num_views
fprintf('computing embedding matrix for view (%d)\n',v);
[U(:,:,v),~] = eigs(W(:,:,v),numClust,'LA',opts);
S = S + beta*U(:,:,v)*U(:,:,v)';
end
S = (S+S')/2;
DA = diag(sum(S));
LA = DA - S;
[H, ~, ~] = eig1(LA, numClust, 0);
zr = 10e-11;
k = 2;
OBJ = zeros(numiter+1,1);
for v =1:num_views
OBJ(1) = OBJ(1) + trace(U(:,:,v)'*LA*U(:,:,v)) + norm(S-beta*U(:,:,v)*U(:,:,v)','fro');
end
while(k<=numiter+1)
fprintf('Running iteration %d\n',k-1);
A0 = zeros(N);
for v = 1:num_views
[U(:,:,v), ~] = eigs(W(:,:,v) + beta.*S, numClust,'LA',opts);
A0 = A0 + beta*U(:,:,v)*U(:,:,v)';
end
for iter = 1:50;
dist = L2_distance_1(H',H');
S = A0.*0;
for j = 1:N
ai = A0(j,:);
di = dist(j,:);
ad = ai - 0.5.*gamma*di;
S(j,:) = EProjSimplex_new(ad);
end;
S = (S + S.')/2;
D = diag(sum(S));
L = D - S;
F_old = H;
[H, ~, ev] = eig1(L, numClust, 0);
fn1 = sum(ev(1:numClust));
fn2 = sum(ev(1:numClust+1));
if fn1 > zr
gamma = gamma.*2;
elseif fn2 < zr
gamma = gamma/2; H = F_old;
else
break;
end;
end
for v =1:num_views
OBJ(k) = OBJ(k) + trace(U(:,:,v)'*L*U(:,:,v)) + norm(S-beta*U(:,:,v)*U(:,:,v)','fro');
end
k = k+1;
end
% plot(OBJ)
[~, y]=graphconncomp(sparse(S)); y = y';
[acc, nmi, Pu] = ClusteringMeasure(truth, y);
AR = RandIndex(truth, y+1);
[F,P,R] = compute_f(truth,y);