Commits

Anonymous committed 9ebcb6a

multi-delay for feedback

  • Participants
  • Parent commits e1eca65

Comments (0)

Files changed (1)

pyrnn/elmannet.py

         self.ns.dUc0 = numpy.zeros((num_c,), dtype=numpy.float)
 
         self.fb_rate  = 1
-        self.fb_delay = 1
+        self.fb_delay = numpy.ones((num_o,), dtype=numpy.int)
         
         self.set_activation()
         self.momentum = 0
         avc = self.avc
         dot = numpy.dot
 
+        fbd = self.fb_delay
         fbr = self.fb_rate
-        fbd = self.fb_delay
         No  = xo.shape[1]
+        dmax = max(fbd.max(),1)
 
-        xo[:fbd] = to[:fbd]
-        xc[fbd-1] = avc(uc[fbd-1])
-        for t in self.ns.time_step[fbd:]:
-            xi[t,:No] = fbr * xo[t-fbd] + (1 - fbr) * to[t-fbd]
+        xo[:dmax] = to[:dmax]
+        xc[dmax-1] = avc(uc[dmax-1])
+        for t in self.ns.time_step[dmax:]:
+            xi[t,:No] = [ fbr * xo[t-d0,o0] + (1 - fbr) * to[t-d0,o0]
+                          for (o0, d0) in enumerate(fbd) ]
             uc[t] = (1-ec)*uc[t-1] + ec*(dot(wci,xi[t])+dot(wcc,xc[t-1])+bc)
             xc[t] = avc(uc[t])
             uo[t] = dot(woc,xc[t])+bo