예제 #1
0
 def updateMatrix(self, matrix):
     if self.pause_remaining:
         self.pause_remaining -= 1
     else:
         #move to new matrix
         self.currentIdx += 1
         self.currentIdx %= len(self.matrices)
         self.pause_remaining = self.pause - 1
         newmat = self.matrices[self.currentIdx]
         
         #copy matrix in
         updateMatrix(matrix, newmat)
예제 #2
0
 def execute(self, data, dataModifyFunc=None, ticks=1, learning=True,
     postTick=None):
     '''
     execute htm pooling across time
     @param data: a mutable array of data for a single time slice
     @param dataModifyFunc: called to mutate data at each time step
     @param ticks: how many iterations of execution to run
     @param learning: whether the htm executes in learning mode
     @param postTick: call this function after every iteration,
         with the htm as an argument
     '''
     updateMatrix(self._data, data)
     
     for _t in xrange(ticks):
         self.__executeOne(learning)
         if postTick:
             postTick(self)
         if dataModifyFunc:
             dataModifyFunc(self._data)