-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo_EAPT_synthetic.m
58 lines (56 loc) · 1.33 KB
/
demo_EAPT_synthetic.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
function [L2_err, cost_time] = demo_EAPT_synthetic(p, c, n, q, r)
addpath('tensor_toolbox_2.6');
addpath('toolbox')
fprintf('Starting...\n');
switch nargin
case 4
r = 5;
case 3
q = 5;
r = 5;
case 2
n = 800;
q = 5;
r = 5;
case 1
c = 0;
n = 800;
q = 5;
r= 5;
case 0
p = 0.45;
c = 0;
n = 800;
q = 5;
r = 5;
end
UU = dctmtx(q);
%% Generate a Tensor RPCA problem
m = n;
A = randn(m, r);
B = randn(r, n*q);
L_unfold = A * B;
L_true = reshape(L_unfold, [m, n, q]);
S_supp_idx = randsample(m*n*q, round(p*m*n*q), false);
S_range = 3.*mean(abs(L_true(:)));
S_temp = 2*S_range*rand(m, n, q) - S_range;
S_true = zeros(m, n, q);
S_true(S_supp_idx) = S_temp(S_supp_idx);
D = L_true + S_true;
Dn = D + randn(size(D)) * c;
para.mu = 1.1*get_mu_tensor(UU, L_true, r);
para.tol = 1e-4;
para.gamma = 0.7;
para.max_iter = 100;
para.p = p;
para.c = c;
para.n = n;
para.q = q;
para.r = r;
para.L = L_true;
tic;
[L2, ~] = EAPT_syn(UU, Dn, r, para);
cost_time = toc;
L2_err = norm(L2(:)-L_true(:), 2)/norm(L_true(:), 2);
fprintf('cost time is %.2f, error is %f\n', cost_time, L2_err);
end