www.pudn.com > RobustSF.zip > DictionaryLearning.asv, change:2014-09-20,size:1394b


function [A,U] = DictionaryLearning(Y, H, Z, lambda, alpha, beta, gamma, tol, max_iter) 
 
addpath PROPACK; 
 
[m,n]=size(Y); 
A=Y; 
E=zeros(m,n); 
Y1=E; 
 
rho = 1.7; 
iter=0; 
mu_bar=1e+10; 
mu1=1e-2; 
yita1=norm(Z,2); 
converged1 = false; 
 
[] 
 
while ~converged1 || ~converged2 
    iter = iter + 1; 
     
    %% update W 
     W=H*A'*pinv(A*A'+lambda*eye(size(A,1))); 
     
    %% updata A 
    yita=yita1+norm(W,2)^2; 
    temp=A-(gamma*A*(Z+Z')+W'*(W*A-H)-mu1*(Y-A-E+Y1/mu1))/(yita*mu1); 
    [U, S, V] = svd(temp); 
    diagS = diag(S); 
    svp = length(find(diagS > alpha/(yita*mu1))); 
    Ak=A; 
    A = U(:, 1:svp) * diag(diagS(1:svp) - alpha/(yita*mu1)) * V(:, 1:svp)'; 
     
    %% update E 
    temp_E=Y-A+Y1/mu1; 
    E = max(temp_E - beta/mu1, 0); 
    E = E + min(temp + beta/mu1, 0); 
 
     
 
    %% stop criterion 
    converged1 = false; 
    temp1=Y-E-A; 
    temp2=A-Ak; 
    stopCriterion1 = norm(temp1, 'fro'); 
    stopCriterion2 = norm(temp2, 'fro'); 
    if stopCriterion1< tol && stopCriterion2 < tol 
        converged1 = true; 
    end  
     
     
    %% update mu1 and mu2 
    mu1 = min(mu1*rho, mu_bar); 
 
     
    %% update Y 
    Y1 = Y1 + mu1*temp1;     
    if converged1 
        break; 
    end 
    if (~converged1) && iter >= max_iter 
        disp('Maximum iterations reached') ; 
        break;    
    end 
end 
 
U=U(:, 1:svp); 
end