-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSNMF_BPGE.m
More file actions
73 lines (71 loc) · 1.85 KB
/
Copy pathSNMF_BPGE.m
File metadata and controls
73 lines (71 loc) · 1.85 KB
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
function [ Aout, xt, error, time] = SNMF_BPGE(y,n_epochs, tau01,tau02, r, Ain, xin)
% Implement BPSG-SARAH for sparse non-negative matrix factorization
% argmin_{A,X} \|Y - AX\|_F^2
% s.t. \|A_k\|_0 <= tau \|X_k\|_0 <= tau \forall k, A_{i,j} >=0, X_{i,j} >= 0
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[n , d] = size(y);
error = zeros(n_epochs,1);
A_old = Ain;
A = Ain;
pn=5;
xi_old = xin;
xi = xin;
norm_y = norm(y,'fro');
t = 1;
time = zeros(n_epochs, 1);
t_total = 0;
e0 = 0.5 * ( norm( A_old * xi_old - y ,'fro') )^2;
md = zeros(1,r);
uy_old = 10000;
u_old = 10000;
for k = 1 : n_epochs
tic;
t=t+1;
beta=0.6*(k-1)/(k+2);
A_t = A +beta*(A- A_old);
A_old = A;
xi_t = xi +beta*(xi-xi_old);
xi_old = xi;
L_A = power_method(A_t, pn);
u = 1/L_A;
u = min(u_old, u);
coeff = 3*(norm(A_t,'fro')^2+norm(xi_t,'fro')^2)+norm_y;
grad01 = A_t'*(A_t*xi_t - y)*u;
grad = grad01 -coeff*xi_t;
xi = -grad;
xi(xi < 0) = 0;
xi=xi';
B = sort(abs(xi), 1, 'descend');
md = B(tau01,:);
for q = 1:r
xi(:,q) = wthresh(xi(:,q),'h',md(q));
end
xi=xi';
L_x = power_method(xi_t, pn);
uy = 1/L_x;
uy = min(uy_old, uy);
grad2 = (xi_t*(A_t*xi_t - y)')'*uy-coeff*A_t;
A = -grad2;
A(A<0) = 0;
B = sort(abs(A), 1, 'descend');
md = B(tau02,:);
for q = 1:r
A(:,q) = wthresh(A(:,q),'h',md(q));
end
xi_norm = norm(xi,'fro')^2;
cor_r_3 = 3*(norm(A,'fro')^2+xi_norm);
r_sol = solve_eq_3(cor_r_3, 0, norm_y, -1);
xi = r_sol*xi;
A = r_sol*A;
u_old = u;
uy_old = uy;
t1 = toc;
t_total = t_total + 2.1*t1;
time(k) = t_total;
error(k) = 0.5 * ( norm( A * xi - y ,'fro') )^2 ;
end
Aout = A;
xt = xi;
error = [e0; error];
end