annotate DL/Majorization Minimization DL/dict_update_REG_fn.m @ 198:83af80baf959 luisf_dev

Reverted SMALL_two_step to the original version; adds path in the Init script.
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Tue, 20 Mar 2012 12:29:47 +0000
parents b14209313ba4
children
rev   line source
ivan@155 1 function [Phiout,unhatnz] = dict_update_REG_fn(Phi,x,unhat,maxIT,eps,cvset)
ivan@155 2 %% Regularized Dictionary Learning with the constraint on the matrix frobenius 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|| = N, 1 = Convex ||D||<=N
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 phim = norm(Phi, 'fro');
ivan@155 15 K = zeros(size(Phi,1),size(Phi,2));
ivan@155 16 c = .1 + svds(unhat,1)^2;
ivan@155 17
ivan@155 18 %%
ivan@155 19 i = 1;
ivan@155 20 while (sum(sum((B-K).^2)) > eps)&&(i<=maxIT)
ivan@155 21 if i>1
ivan@155 22 B = K;
ivan@155 23 end
ivan@155 24 K = 1/c *(x*unhat' + B*(c*eye(size(B,2))-unhat*unhat'));
ivan@155 25 Kfn = sum(sum(K.^2));
ivan@155 26 if cvset == 1,
ivan@155 27 K = min(1,phim/Kfn)*K; % with convex constraint set
ivan@155 28 else
ivan@155 29 K = (phim/Kfn)*K; % with fixed-norm constraint set
ivan@155 30 end
ivan@155 31 i = i+1;
ivan@155 32 end
ivan@155 33
ivan@155 34 %% depleted atoms cancellation %%%
ivan@155 35 [Y,I] = sort(sum(K.^2),'descend');
ivan@155 36 RR = sum(Y>=0.0001);
ivan@155 37 Phiout = K(:,I(1:RR));
ivan@155 38 unhatnz = unhat(I(1:RR),:);
ivan@155 39 end