comparison util/SMALL_learn.m @ 152:485747bf39e0 ivand_dev

Two step dictonary learning - Integration of the code for dictionary update and dictionary decorrelation from Boris Mailhe
author Ivan Damnjanovic lnx <ivan.damnjanovic@eecs.qmul.ac.uk>
date Thu, 28 Jul 2011 15:49:32 +0100
parents 5ded5e2e7d07
children b14209313ba4
comparison
equal deleted inserted replaced
149:fec205ec6ef6 152:485747bf39e0
16 % modify it under the terms of the GNU General Public License as 16 % modify it under the terms of the GNU General Public License as
17 % published by the Free Software Foundation; either version 2 of the 17 % published by the Free Software Foundation; either version 2 of the
18 % License, or (at your option) any later version. See the file 18 % License, or (at your option) any later version. See the file
19 % COPYING included with this distribution for more information. 19 % COPYING included with this distribution for more information.
20 %% 20 %%
21 21 if (DL.profile)
22 fprintf('\nStarting Dictionary Learning %s... \n', DL.name); 22 fprintf('\nStarting Dictionary Learning %s... \n', DL.name);
23 end
23 start=cputime; 24 start=cputime;
24 tStart=tic; 25 tStart=tic;
25 if strcmpi(DL.toolbox,'KSVD') 26 if strcmpi(DL.toolbox,'KSVD')
26 param=DL.param; 27 param=DL.param;
27 param.data=Problem.b; 28 param.data=Problem.b;
56 57
57 for i = 1: size(D,2) 58 for i = 1: size(D,2)
58 D(:,i)=D(:,i)/norm(D(:,i)); 59 D(:,i)=D(:,i)/norm(D(:,i));
59 end 60 end
60 61
62 elseif strcmpi(DL.toolbox,'TwoStepDL')
63
64 DL=SMALL_two_step_DL(Problem, DL);
65
66 % we need to make sure that columns are normalised to
67 % unit lenght.
68
69 for i = 1: size(DL.D,2)
70 DL.D(:,i)=DL.D(:,i)/norm(DL.D(:,i));
71 end
72 D = DL.D;
61 % To introduce new dictionary learning technique put the files in 73 % To introduce new dictionary learning technique put the files in
62 % your Matlab path. Next, unique name <TolboxID> for your toolbox needs 74 % your Matlab path. Next, unique name <TolboxID> for your toolbox needs
63 % to be defined and also prefferd API for toolbox functions <Preffered_API> 75 % to be defined and also prefferd API for toolbox functions <Preffered_API>
64 % 76 %
65 % elseif strcmpi(DL.toolbox,'<ToolboxID>') 77 % elseif strcmpi(DL.toolbox,'<ToolboxID>')
81 end 93 end
82 94
83 %% 95 %%
84 % Dictionary Learning time 96 % Dictionary Learning time
85 tElapsed=toc(tStart); 97 tElapsed=toc(tStart);
86 DL.time = cputime - start; 98 DL.time = cputime - start;
99 if (DL.profile)
87 fprintf('\n%s finished task in %2f seconds (cpu time). \n', DL.name, DL.time); 100 fprintf('\n%s finished task in %2f seconds (cpu time). \n', DL.name, DL.time);
88 fprintf('\n%s finished task in %2f seconds (tic-toc time). \n', DL.name, tElapsed); 101 fprintf('\n%s finished task in %2f seconds (tic-toc time). \n', DL.name, tElapsed);
102 end
89 DL.time=tElapsed; 103 DL.time=tElapsed;
90 % If dictionary is given as a sparse matrix change it to full 104 % If dictionary is given as a sparse matrix change it to full
91 105
92 DL.D = full(D); 106 DL.D = full(D);
93 107