Example #1
0
 def __executeOne(self, learning):
     from numenta.htm import pool_spatial, pool_temporal
     
     for cell in self.cells:
         cell.clockTick()
             
     pool_spatial(self)
     
     self._updateSegments = pool_temporal(self, self._updateSegments, learning=learning)
     
     #non-Numenta optimization:
     #track whether cell is predicted next
     #penalize near segments for failing immediately
     if EXTENSION_NEXT_STEP_PENALTY:
         for cell in self.cells:
             #mark prediction of immediate next step
             cell.predictingNext = False
             for segment in cell.segmentsNear:
                 if segment.active:
                     cell.predictingNext = True
                 
             if cell.predictedNext and not cell.active:
                 #penalize only active near segments
                 otherSynapseStates = []
                 for synapses in self._updateSegments[cell]:
                     if len(synapses) and synapses[0].segment == segment:
                         Segment.adapt_down(synapses)
                     else:
                         otherSynapseStates.append(synapses)
                         
                 self._updateSegments.reset(cell)
                 self._updateSegments.addAll(cell, otherSynapseStates)
Example #2
0
    def __executeOne(self, learning):
        from numenta.htm import pool_spatial, pool_temporal

        for cell in self.cells:
            cell.clockTick()

        pool_spatial(self)

        self._updateSegments = pool_temporal(self,
                                             self._updateSegments,
                                             learning=learning)

        #non-Numenta optimization:
        #track whether cell is predicted next
        #penalize near segments for failing immediately
        if EXTENSION_NEXT_STEP_PENALTY:
            for cell in self.cells:
                #mark prediction of immediate next step
                cell.predictingNext = False
                for segment in cell.segmentsNear:
                    if segment.active:
                        cell.predictingNext = True

                if cell.predictedNext and not cell.active:
                    #penalize only active near segments
                    otherSynapseStates = []
                    for synapses in self._updateSegments[cell]:
                        if len(synapses) and synapses[0].segment == segment:
                            Segment.adapt_down(synapses)
                        else:
                            otherSynapseStates.append(synapses)

                    self._updateSegments.reset(cell)
                    self._updateSegments.addAll(cell, otherSynapseStates)
Example #3
0
def _temporal_phase3(htm, updateSegments):
    'Phase 3, p42'
    for cell in htm.cells:
        if cell.learning:
            for synapseStates in updateSegments[cell]:
                Segment.adapt_up(synapseStates)
            updateSegments.reset(cell)
        elif not cell.predicting and cell.predicted:
            for synapseStates in updateSegments[cell]:
                Segment.adapt_down(synapseStates)
            updateSegments.reset(cell)
            
    return updateSegments
Example #4
0
def _temporal_phase3(htm, updateSegments):
    'Phase 3, p42'
    for cell in htm.cells:
        if cell.learning:
            for synapseStates in updateSegments[cell]:
                Segment.adapt_up(synapseStates)
            updateSegments.reset(cell)
        elif not cell.predicting and cell.predicted:
            for synapseStates in updateSegments[cell]:
                Segment.adapt_down(synapseStates)
            updateSegments.reset(cell)

    return updateSegments
Example #5
0
 def testAdaptation(self):
     seg = Segment()
     
     #for now, just don't crash
     seg.adapt_up([])
     seg.adapt_down([])
Example #6
0
    def testAdaptation(self):
        seg = Segment()

        #for now, just don't crash
        seg.adapt_up([])
        seg.adapt_down([])