ivan@155
|
1 function [Phiout,unhatnz] = dict_update_REG_cn(Phi,x,unhat,maxIT,eps,cvset)
|
ivan@155
|
2 %% Regularized Dictionary Learning with the constraint on the column norms %%%%%
|
ivan@155
|
3 % Phi = Normalized Initial Dictionary
|
ivan@155
|
4 % x = Signal(x). This can be a vector or a matrix
|
ivan@155
|
5 % unhat = Initial guess for the coefficients
|
ivan@155
|
6 % to = 1/(step size) . It is larger than spectral norm of coefficient matrix x
|
ivan@155
|
7 % eps = Stopping criterion for iterative softthresholding and MM dictionary update
|
ivan@155
|
8 % cvset = Dictionary constraint. 0 = Non convex ||d|| = 1, 1 = Convex ||d||<=1
|
ivan@155
|
9 % Phiout = Updated Dictionary
|
ivan@155
|
10 % unhatnz Updated Coefficients (the same as input in this version)
|
ivan@155
|
11
|
ivan@155
|
12 %%
|
ivan@155
|
13 B = Phi;
|
ivan@155
|
14 K = zeros(size(Phi,1),size(Phi,2));
|
ivan@155
|
15 c = .1 + svds(unhat,1)^2; %.1
|
ivan@155
|
16 c3 = (1/c)*eye(size(B,2));
|
ivan@155
|
17 c1 = x*unhat'*c3;
|
ivan@155
|
18 c2 = (c*eye(size(B,2))-unhat*unhat')*c3;
|
ivan@155
|
19
|
ivan@155
|
20 %%
|
ivan@155
|
21
|
ivan@155
|
22 for i=1:maxIT
|
ivan@155
|
23 % if i>1
|
ivan@155
|
24 % B = K;
|
ivan@155
|
25 % end
|
ivan@155
|
26
|
ivan@155
|
27 K = c1 + B*c2;
|
ivan@155
|
28
|
ivan@155
|
29 if cvset == 1,
|
ivan@155
|
30 K = K*diag(min(sum(K.^2).^(-.5),1)); % with convex constraint set
|
ivan@155
|
31 else
|
ivan@155
|
32 % Mehrdad original -
|
ivan@155
|
33 % K = K*diag(sum(K.^2).^(-.5)); % with fixed-norm constraint set
|
ivan@155
|
34 K = normc(K);
|
ivan@155
|
35 end
|
ivan@155
|
36
|
ivan@155
|
37 if (sum(sum((B-K).^2)) < eps)
|
ivan@155
|
38 break;
|
ivan@155
|
39 end
|
ivan@155
|
40
|
ivan@155
|
41 B = K;
|
ivan@155
|
42 end
|
ivan@155
|
43 %% depleted atoms cancellation %%%
|
ivan@155
|
44 [Y,I] = sort(sum(K.^2),'descend');
|
ivan@155
|
45 RR = sum(Y>=.01);
|
ivan@155
|
46 Phiout = K(:,I(1:RR));
|
ivan@155
|
47 unhatnz = unhat(I(1:RR),:);
|
ivan@155
|
48 end |