Mercurial > hg > smallbox
comparison DL/Majorization Minimization DL/ExactDicoRecovery/ksvd_cn.m @ 159:23763c5fbda5 danieleb
Merge
author | Daniele Barchiesi <daniele.barchiesi@eecs.qmul.ac.uk> |
---|---|
date | Wed, 31 Aug 2011 10:43:32 +0100 |
parents | b14209313ba4 |
children |
comparison
equal
deleted
inserted
replaced
158:855aa3288394 | 159:23763c5fbda5 |
---|---|
1 % K-SVD algorithm for Dictionary Learning | |
2 % Y = input data (M X L matrix) | |
3 % Phi = initial dictionary (M X N), e.g. random dictionary or first N data samples | |
4 % lambda = regularization coefficient (||Phi*X-Y||_F)^2 + lambda*||X||_1 | |
5 % IT = number of iterations | |
6 function [Phiout,X,ert] = ksvd_cn(Y,Phi,lambda,IT) | |
7 maxIT = 1000; | |
8 [PhiN,PhiM] = size(Phi); | |
9 RR1 = PhiM; | |
10 %%%%%%%%%%%%%% | |
11 % [PhiM,L] = size(ud); | |
12 [PhiN,L] = size(Y); | |
13 X = ones(PhiM,L); | |
14 for it = 1:IT | |
15 to = .1+svds(Phi,1); | |
16 [PhiN,PhiM] = size(Phi); | |
17 %%%% | |
18 eps = 3*10^-4; | |
19 map = 1; % Projecting on the selected space (0=no,1=yes) | |
20 [X,l1err] = mm1(Phi,Y,X,to,lambda,maxIT,eps,map); %% Sparse approximation with Iterative Soft-thresholding | |
21 ert(it) = l1err; | |
22 %%% | |
23 [Phi,X] = dict_update_KSVD_cn(Phi,Y,X); | |
24 end | |
25 Phiout = Phi; |