comparison DL/two-step DL/SMALL_two_step_DL.m @ 176:d0645d5fca7d danieleb

added MOCOD dictionary update
author Daniele Barchiesi <daniele.barchiesi@eecs.qmul.ac.uk>
date Thu, 17 Nov 2011 11:17:44 +0000
parents 68fb71aa5339
children fd0b5d36f6ad
comparison
equal deleted inserted replaced
175:9eb5f0d4c1a4 176:d0645d5fca7d
2 2
3 % determine which solver is used for sparse representation % 3 % determine which solver is used for sparse representation %
4 4
5 solver = DL.param.solver; 5 solver = DL.param.solver;
6 6
7 % determine which type of udate to use ('KSVD', 'MOD', 'ols' or 'mailhe') % 7 % determine which type of udate to use ('KSVD', 'MOD','MOCOD','ols' or 'mailhe') %
8 8
9 typeUpdate = DL.name; 9 typeUpdate = DL.name;
10 10
11 sig = Problem.b; 11 sig = Problem.b;
12 12
81 mu = DL.param.coherence; 81 mu = DL.param.coherence;
82 else 82 else
83 decorrelate = 0; 83 decorrelate = 0;
84 end 84 end
85 85
86 if ~isfield(DL.param,'decFcn'), DL.param.decFcn = 'none'; end
87
86 % show dictonary every specified number of iterations 88 % show dictonary every specified number of iterations
87 89
88 if isfield(DL.param,'show_dict') 90 if isfield(DL.param,'show_dict')
89 show_dictionary=1; 91 show_dictionary=1;
90 show_iter=DL.param.show_dict; 92 show_iter=DL.param.show_dict;
107 109
108 % main loop % 110 % main loop %
109 111
110 for i = 1:iternum 112 for i = 1:iternum
111 %disp([num2str(i) '/' num2str(iternum)]); 113 %disp([num2str(i) '/' num2str(iternum)]);
112 Problem.A = dico; 114 %SPARSE CODING STEP
115 Problem.A = dico;
113 solver = SMALL_solve(Problem, solver); 116 solver = SMALL_solve(Problem, solver);
114 [dico, solver.solution] = dico_update(dico, sig, solver.solution, ... 117 %DICTIONARY UPDATE STEP
115 typeUpdate, flow, learningRate); 118 if strcmpi(typeUpdate,'mocod') %if update is MOCOD create parameters structure
116 dico = normcols(dico); 119 mocodParams = struct('zeta',DL.param.zeta,... %coherence regularization factor
120 'eta',DL.param.eta,... %atoms norm regularization factor
121 'Dprev',dico); %previous dictionary
122 dico = dico_update(dico,sig,solver.solution,typeUpdate,flow,learningRate,mocodParams);
123 else
124 [dico, solver.solution] = dico_update(dico, sig, solver.solution, ...
125 typeUpdate, flow, learningRate);
126 dico = normcols(dico);
127 end
128
117 switch lower(DL.param.decFcn) 129 switch lower(DL.param.decFcn)
118 case 'ink-svd' 130 case 'ink-svd'
119 dico = dico_decorr_symetric(dico,mu,solver.solution); 131 dico = dico_decorr_symetric(dico,mu,solver.solution);
120 case 'grassmannian' 132 case 'grassmannian'
121 [n m] = size(dico); 133 [n m] = size(dico);