-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_CUR_lupp_bound.m
107 lines (102 loc) · 3.5 KB
/
main_CUR_lupp_bound.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
%% load input data
clear; close;
% path = '/h2/yijun/Documents/MATLAB/RandNLA/CUR/';
% path_target = '/h2/yijun/Documents/MATLAB/RandNLA/dataset/';
path_target = '/Users/ydong/Documents/MATLAB/OdenUT/RandNLA/dataset/';
path = '/Users/ydong/Documents/MATLAB/OdenUT/RandNLA/CUR/';
% tag = 'large';
% tag = 'snn-1e3-1e3_a2b1_k100_r1e3_s1e-3';
% tag = 'yaleface-64x64';
% tag = 'mnist-train';
% tag = 'GSE10072';
% tag = 'ACTIVSg2000';
% tag = 'p2p-Gnutella09';
% tag = 'weightedlaplacian-n1e3-m4e3';
% target = load(strcat(path_target, sprintf('target_%s.mat',tag)));
% A = target.A;
% k = load(sprintf('rank_%s.mat',tag)); k = k.k;
% test_CUR_rank(k, target, tag, [])
% scp yijun@natt.oden.utexas.edu:/h2/yijun/Documents/MATLAB/RandNLA/CUR/*_ACTIVSg2000.mat
% tag = strcat(tag,'-srcur');
% algos = {'SRCUR','CPQR','LUPP','LUPP2pass','RSVDDEIM','RSVDLS'};
% test_CUR_rank(k, target, tag, algos);
%%
tags = struct('large','large',...
'snn','snn-1e3-1e3_a2b1_k100_r1e3_s1e-3',...
'yaleface','yaleface-64x64',...
'mnist','mnist-train');
des = struct('large','large: $4282 \times 8617$',...
'snn','SNN: $1000 \times 1000$',...
'yaleface','YaleFace: $165 \times 4096$',...
'mnist','MNIST training: $60000 \times 784$');
k = 10:10:150;
%%
repeat = 10;
eta2 = struct('rank',k);
etaf = struct('rank',k);
labels = fieldnames(tags);
for idx = 1:length(labels)
label = labels{idx};
tag = tags.(label);
target = load(strcat(path_target, sprintf('target_%s.mat',tag)));
A = target.A;
eta2.(label) = zeros(2,size(k,2));
etaf.(label) = zeros(2,size(k,2));
for i =1:length(k)
eta2sum = 0;
etafsum = 0;
g2sum = 0;
gfsum = 0;
for t = 1:repeat
S = embed(size(A,2), k(i), 'gauss');
Y = S(A')';
[L,~,~] = lu(Y,'vec');
L2 = L(k(i)+1:end,:);
L1 = L(1:k(i),:);
aux = (L1'\L2')';
eta2sum = eta2sum + norm(aux);
etafsum = etafsum + norm(aux,'fro');
G = randn(size(Y));
[Lg,~,~] = lu(G,'vec');
Lg1 = Lg(1:k(i),:); % (k,k)
Lg2 = Lg(k(i)+1:end,:); % (m-k,k)
aux = (Lg1'\Lg2')';
g2sum = g2sum + norm(aux);
gfsum = gfsum + norm(aux,'fro');
end
eta2.(label)(1,i) = eta2sum / repeat;
etaf.(label)(1,i) = etafsum / repeat;
eta2.(label)(2,i) = g2sum / repeat;
etaf.(label)(2,i) = gfsum / repeat;
fprintf('%d / %d \n', i, length(k))
end
end
%%
figure()
for idx = 1:length(labels)
label = labels{idx};
tag = tags.(label);
e2 = eta2.(label)(1,:);
ef = etaf.(label)(1,:);
g2 = eta2.(label)(2,:);
gf = etaf.(label)(2,:);
k = eta2.rank;
subplot(2,2,idx)
plot(k, e2, 'r.-', 'MarkerSize',20, 'LineWidth', 1.5)
hold on
plot(k, ef, 'b.-', 'MarkerSize',20, 'LineWidth', 1.5)
plot(k, g2, 'rs:', 'MarkerSize',5, 'LineWidth', 1.5)
plot(k, gf, 'bs:', 'MarkerSize',5, 'LineWidth', 1.5)
hold off
title(des.(label), 'interpreter','latex')
xlabel('$l$', 'interpreter','latex')
ylabel('$||L_2 L_1^{-1}||$', 'interpreter','latex')
if idx==1
legend('$||.||_2$',...
'$||.||_F$',...
'Gaussian $||.||_2$',...
'Gaussian $||.||_F$',...
'interpreter','latex')
end
set(gca,'Fontsize',12)
end