Mercurial > hg > smallbox
comparison DL/two-step DL/SMALL_two_step_DL.m @ 220:0d30f9074dd9
Merge
author | luisf <luis.figueira@eecs.qmul.ac.uk> |
---|---|
date | Wed, 11 Apr 2012 15:56:39 +0100 |
parents | f12a476a4977 |
children | fd0b5d36f6ad |
comparison
equal
deleted
inserted
replaced
165:775caafd5651 | 220:0d30f9074dd9 |
---|---|
1 function DL=SMALL_two_step_DL(Problem, DL) | 1 function DL=SMALL_two_step_DL(Problem, DL) |
2 | |
3 %% DL=SMALL_two_step_DL(Problem, DL) learn a dictionary using two_step_DL | |
4 % The specific parameters of the DL structure are: | |
5 % -name: can be either 'ols', 'opt', 'MOD', KSVD' or 'LGD'. | |
6 % -param.learningRate: a step size used by 'ols' and 'opt'. Default: 0.1 | |
7 % for 'ols', 1 for 'opt'. | |
8 % -param.flow: can be either 'sequential' or 'parallel'. De fault: | |
9 % 'sequential'. Not used by MOD. | |
10 % -param.coherence: a real number between 0 and 1. If present, then | |
11 % a low-coherence constraint is added to the learning. | |
12 % | |
13 % See dico_update.m for more details. | |
2 | 14 |
3 % determine which solver is used for sparse representation % | 15 % determine which solver is used for sparse representation % |
4 | 16 |
5 solver = DL.param.solver; | 17 solver = DL.param.solver; |
6 | 18 |
7 % determine which type of udate to use ('KSVD', 'MOD', 'ols' or 'mailhe') % | 19 % determine which type of udate to use ('KSVD', 'MOD', 'ols', 'opt' or 'LGD') % |
8 | 20 |
9 typeUpdate = DL.name; | 21 typeUpdate = DL.name; |
10 | 22 |
11 sig = Problem.b; | 23 sig = Problem.b; |
12 | 24 |
55 else | 67 else |
56 flow = 'sequential'; | 68 flow = 'sequential'; |
57 end | 69 end |
58 | 70 |
59 % learningRate. If the type is 'ols', it is the descent step of | 71 % learningRate. If the type is 'ols', it is the descent step of |
60 % the gradient (typical choice: 0.1). If the type is 'mailhe', the | 72 % the gradient (default: 0.1). If the type is 'mailhe', the |
61 % descent step is the optimal step*rho (typical choice: 1, although 2 | 73 % descent step is the optimal step*rho (default: 1, although 2 works |
62 % or 3 seems to work better). Not used for MOD and KSVD. | 74 % better). Not used for MOD and KSVD. |
63 | 75 |
64 if isfield(DL.param,'learningRate') | 76 if isfield(DL.param,'learningRate') |
65 learningRate = DL.param.learningRate; | 77 learningRate = DL.param.learningRate; |
66 else | 78 else |
67 learningRate = 0.1; | 79 switch typeUpdate |
80 case 'ols' | |
81 learningRate = 0.1; | |
82 otherwise | |
83 learningRate = 1; | |
84 end | |
68 end | 85 end |
69 | 86 |
70 % number of iterations (default is 40) % | 87 % number of iterations (default is 40) % |
71 | 88 |
72 if isfield(DL.param,'iternum') | 89 if isfield(DL.param,'iternum') |
111 Problem.A = dico; | 128 Problem.A = dico; |
112 solver = SMALL_solve(Problem, solver); | 129 solver = SMALL_solve(Problem, solver); |
113 [dico, solver.solution] = dico_update(dico, sig, solver.solution, ... | 130 [dico, solver.solution] = dico_update(dico, sig, solver.solution, ... |
114 typeUpdate, flow, learningRate); | 131 typeUpdate, flow, learningRate); |
115 if (decorrelate) | 132 if (decorrelate) |
116 dico = dico_decorr(dico, mu, solver.solution); | 133 dico = dico_decorr_symetric(dico, mu, solver.solution); |
117 end | 134 end |
118 | 135 |
119 if ((show_dictionary)&&(mod(i,show_iter)==0)) | 136 if ((show_dictionary)&&(mod(i,show_iter)==0)) |
120 dictimg = SMALL_showdict(dico,[8 8],... | 137 dictimg = SMALL_showdict(dico,[8 8],... |
121 round(sqrt(size(dico,2))),round(sqrt(size(dico,2))),'lines','highcontrast'); | 138 round(sqrt(size(dico,2))),round(sqrt(size(dico,2))),'lines','highcontrast'); |