changeset 208:36b02a8d0add luisf_dev

merge
author bmailhe
date Wed, 21 Mar 2012 14:13:31 +0000
parents 233e75809e4a (diff) 2882992f9e6e (current diff)
children dfa795944aae
files
diffstat 1 files changed, 18 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/DL/two-step DL/dico_update.m	Tue Mar 20 16:17:12 2012 +0000
+++ b/DL/two-step DL/dico_update.m	Wed Mar 21 14:13:31 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