comparison DL/two-step DL/SMALL_two_step_DL.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 d50f5bdbe14c
children dfa795944aae
comparison
equal deleted inserted replaced
197:d00e97b2f1cb 198:83af80baf959
28 end 28 end
29 29
30 30
31 % initialize the dictionary % 31 % initialize the dictionary %
32 32
33 % todo: check second if statement 33 if (isfield(DL.param,'initdict'))
34 if (isfield(DL.param,'initdict')) && ~isempty(DL.param.initdict);
35 if (any(size(DL.param.initdict)==1) && all(iswhole(DL.param.initdict(:)))) 34 if (any(size(DL.param.initdict)==1) && all(iswhole(DL.param.initdict(:))))
36 dico = sig(:,DL.param.initdict(1:dictsize)); 35 dico = sig(:,DL.param.initdict(1:dictsize));
37 else 36 else
38 if (size(DL.param.initdict,1)~=size(sig,1) || size(DL.param.initdict,2)<dictsize) 37 if (size(DL.param.initdict,1)~=size(sig,1) || size(DL.param.initdict,2)<dictsize)
39 error('Invalid initial dictionary'); 38 error('Invalid initial dictionary');
96 95
97 % This is a small patch that needs to be resolved in dictionary learning we 96 % This is a small patch that needs to be resolved in dictionary learning we
98 % want sparse representation of training set, and in Problem.b1 in this 97 % want sparse representation of training set, and in Problem.b1 in this
99 % version of software we store the signal that needs to be represented 98 % version of software we store the signal that needs to be represented
100 % (for example the whole image) 99 % (for example the whole image)
101 global SMALL_path
102 100
103 tmpTraining = Problem.b1; 101 tmpTraining = Problem.b1;
104 Problem.b1 = sig; 102 Problem.b1 = sig;
105 if isfield(Problem,'reconstruct') 103 if isfield(Problem,'reconstruct')
106 Problem = rmfield(Problem, 'reconstruct'); 104 Problem = rmfield(Problem, 'reconstruct');
110 % main loop % 108 % main loop %
111 109
112 for i = 1:iternum 110 for i = 1:iternum
113 Problem.A = dico; 111 Problem.A = dico;
114 solver = SMALL_solve(Problem, solver); 112 solver = SMALL_solve(Problem, solver);
115 113 [dico, solver.solution] = dico_update(dico, sig, solver.solution, ...
116 % configuration file 114 typeUpdate, flow, learningRate);
117 run([SMALL_path '/config/SMALL_two_step_DL_config.m']) 115 if (decorrelate)
118 116 dico = dico_decorr(dico, mu, solver.solution);
119 % [dico, solver.solution] = dico_update(dico, sig, solver.solution, ... 117 end
120 % typeUpdate, flow, learningRate);
121 % if (decorrelate)
122 % dico = dico_decorr(dico, mu, solver.solution);
123 % end
124 118
125 if ((show_dictionary)&&(mod(i,show_iter)==0)) 119 if ((show_dictionary)&&(mod(i,show_iter)==0))
126 dictimg = SMALL_showdict(dico,[8 8],... 120 dictimg = SMALL_showdict(dico,[8 8],...
127 round(sqrt(size(dico,2))),round(sqrt(size(dico,2))),'lines','highcontrast'); 121 round(sqrt(size(dico,2))),round(sqrt(size(dico,2))),'lines','highcontrast');
128 figure(2); imagesc(dictimg);colormap(gray);axis off; axis image; 122 figure(2); imagesc(dictimg);colormap(gray);axis off; axis image;