class ExtendedTMCPP_ApicalTiebreakSequencesTests( ApicalTiebreakSequencesTestBase, unittest.TestCase): """ Run the apical tiebreak sequence tests on the C++ ExtendedTemporalMemory. """ def constructTM(self, columnCount, apicalInputSize, cellsPerColumn, initialPermanence, connectedPermanence, minThreshold, sampleSize, permanenceIncrement, permanenceDecrement, predictedSegmentDecrement, activationThreshold, seed): params = { "apicalInputDimensions": (apicalInputSize, ), "columnDimensions": (columnCount, ), "cellsPerColumn": cellsPerColumn, "initialPermanence": initialPermanence, "connectedPermanence": connectedPermanence, "minThreshold": minThreshold, "maxNewSynapseCount": sampleSize, "permanenceIncrement": permanenceIncrement, "permanenceDecrement": permanenceDecrement, "predictedSegmentDecrement": predictedSegmentDecrement, "activationThreshold": activationThreshold, "seed": seed, "learnOnOneCell": False, "formInternalBasalConnections": True, } self.tm = ExtendedTemporalMemory(**params) def compute(self, activeColumns, apicalInput, learn): activeColumns = sorted(activeColumns) apicalInput = sorted(apicalInput) # Use depolarizeCells + activateCells rather than tm.compute so that # getPredictiveCells returns predictions for the current timestep. self.tm.depolarizeCells(activeCellsExternalApical=apicalInput, learn=learn) self.tm.activateCells(activeColumns, reinforceCandidatesExternalApical=apicalInput, growthCandidatesExternalApical=apicalInput, learn=learn) def reset(self): self.tm.reset() def getActiveCells(self): return self.tm.getActiveCells() def getPredictedCells(self): return self.tm.getPredictiveCells()
class ExtendedTMCPP_SequenceMemoryTests(SequenceMemoryTestBase, unittest.TestCase): """ Run the sequence memory tests on the C++ ExtendedTemporalMemory. """ def constructTM(self, columnCount, cellsPerColumn, initialPermanence, connectedPermanence, minThreshold, sampleSize, permanenceIncrement, permanenceDecrement, predictedSegmentDecrement, activationThreshold, seed): params = { "columnDimensions": (columnCount,), "cellsPerColumn": cellsPerColumn, "initialPermanence": initialPermanence, "connectedPermanence": connectedPermanence, "minThreshold": minThreshold, "maxNewSynapseCount": sampleSize, "permanenceIncrement": permanenceIncrement, "permanenceDecrement": permanenceDecrement, "predictedSegmentDecrement": predictedSegmentDecrement, "activationThreshold": activationThreshold, "seed": seed, "learnOnOneCell": False, } self.tm = ExtendedTemporalMemory(**params) def compute(self, activeColumns, learn): # Use depolarizeCells + activateCells rather than tm.compute so that # getPredictiveCells returns predictions for the current timestep. self.tm.depolarizeCells(learn=learn) self.tm.activateCells(sorted(activeColumns), learn=learn) def reset(self): self.tm.reset() def getActiveCells(self): return self.tm.getActiveCells() def getPredictedCells(self): return self.tm.getPredictiveCells()