Mercurial > hg > smallbox
comparison DL/Majorization Minimization DL/Demo.m @ 155:b14209313ba4 ivand_dev
Integration of Majorization Minimisation Dictionary Learning
author | Ivan Damnjanovic lnx <ivan.damnjanovic@eecs.qmul.ac.uk> |
---|---|
date | Mon, 22 Aug 2011 11:46:35 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
154:0de08f68256b | 155:b14209313ba4 |
---|---|
1 clear | |
2 M = 20; % Signal length | |
3 N = 40; % Coefficient Space Dimension | |
4 L = 32*N; % Number of Training Samples | |
5 R = 3; % Sparsity | |
6 IT = 1000; % Number of alternating sparse approximation and dictionary update | |
7 map = 1; % Debiasing. 0 = No, 1 = Yes | |
8 maxIT = 1000; % Inner-loop maximum iteration number. | |
9 lambda = 2*.2; % Lagrangian multiplier. | |
10 epsx = 10^-7; % Stopping criterion for iterative softthresholding | |
11 epsd = 10^-7; % Stopping criterion for MM dictionary update | |
12 cvset = 0; % Dictionary constraint. 0 = Non convex ||d|| = 1, 1 = Convex ||d||<=1 | |
13 Tre = .99; % Threshold for accepting too atoms identical | |
14 %%%% Generative Dictionaries | |
15 Do = randn(M,N); % Generative Dictionary | |
16 Do = Do*(diag(sum((Do'*Do).*eye(length(Do))).^-.5)); % Normalization | |
17 %%%% Sparse signal generation %%%%% | |
18 Xo = zeros(N,L); % Original Sparse Coefficients | |
19 for l = 1:L | |
20 r = 1; | |
21 while r<=R | |
22 ind = fix(rand(1)*N)+ones(1); | |
23 a = rand(1); | |
24 if Xo(ind)==0 | |
25 Xo(ind,l) = (.8*rand(1)+.2)*((a>=.5)-(a<.5)); | |
26 r = r+1; | |
27 end | |
28 end | |
29 end | |
30 Y = Do*Xo; % Sparse Signals | |
31 %%%% Algorithm initialization | |
32 D = randn(M,N); % Initial Dictionary | |
33 D = D*(diag(sum((D'*D).*eye(length(D))).^-.5)); % Normalization | |
34 X = ones(size(Xo)); % Initial coefficients | |
35 for it = 1:IT, | |
36 it | |
37 to = .1+svds(D,1); | |
38 [X,cost(it)] = mm1(D,Y,X,to,lambda,maxIT,epsx,map); | |
39 plot(cost); | |
40 [D,X] = dict_update_REG_cn(D,Y,X,maxIT,epsd,cvset); | |
41 end | |
42 %%% | |
43 success = sum(max(abs((Do'*D)))>=Tre); | |
44 display([' ------------------']) | |
45 display([' ',num2str(success),'% of the atoms successfully recovered after ',num2str(IT),' iterations.']); |