Mercurial > hg > smallbox
changeset 207:233e75809e4a luisf_dev
Accelerated the code for LGD and optimal grandient descent
author | bmailhe |
---|---|
date | Wed, 21 Mar 2012 14:12:25 +0000 |
parents | 5bb579c9874e |
children | 36b02a8d0add |
files | DL/two-step DL/dico_update.m |
diffstat | 1 files changed, 18 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/DL/two-step DL/dico_update.m Tue Mar 20 14:51:31 2012 +0000 +++ b/DL/two-step DL/dico_update.m Wed Mar 21 14:12:25 2012 +0000 @@ -86,13 +86,28 @@ end case 'opt' for p = 1:nb_pattern - vec : amp(p,:); - grad = res*vec'; + index = find(amp(p,:)~=0); + vec = amp(p,index); + grad = res(:,index)*vec'; if norm(grad) > 0 pat = (vec*vec')*dico(:,p) + rho*grad; pat = pat/norm(pat); if nargin >5 && strcmp(flow, 'sequential') - res = res + (dico(:,p)-pat)*vec; + res(:,index) = res(:,index) + (dico(:,p)-pat)*vec; + end + dico(:,p) = pat; + end + end + case 'LGD' + for p = 1:nb_pattern + index = find(amp(p,:)~=0); + vec = amp(p,index); + grad = res(:,index)*vec'; + if norm(grad) > 0 + pat = (vec*vec')*dico(:,p) + 2*grad; + pat = pat/norm(pat); + if nargin >5 && strcmp(flow, 'sequential') + res(:,index) = res(:,index) + (dico(:,p)-pat)*vec; end dico(:,p) = pat; end