本文整理汇总了Python中nupic.algorithms.temporal_memory.TemporalMemory.createSegment方法的典型用法代码示例。如果您正苦于以下问题:Python TemporalMemory.createSegment方法的具体用法?Python TemporalMemory.createSegment怎么用?Python TemporalMemory.createSegment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nupic.algorithms.temporal_memory.TemporalMemory
的用法示例。
在下文中一共展示了TemporalMemory.createSegment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testPredictedActiveCellsAreAlwaysWinners
# 需要导入模块: from nupic.algorithms.temporal_memory import TemporalMemory [as 别名]
# 或者: from nupic.algorithms.temporal_memory.TemporalMemory import createSegment [as 别名]
def testPredictedActiveCellsAreAlwaysWinners(self):
tm = TemporalMemory(
columnDimensions=[32],
cellsPerColumn=4,
activationThreshold=3,
initialPermanence=.21,
connectedPermanence=.5,
minThreshold=2,
maxNewSynapseCount=3,
permanenceIncrement=.10,
permanenceDecrement=.10,
predictedSegmentDecrement=0.0,
seed=42)
previousActiveColumns = [0]
activeColumns = [1]
previousActiveCells = [0, 1, 2, 3]
expectedWinnerCells = [4, 6]
activeSegment1 = tm.createSegment(expectedWinnerCells[0])
tm.connections.createSynapse(activeSegment1, previousActiveCells[0], .5)
tm.connections.createSynapse(activeSegment1, previousActiveCells[1], .5)
tm.connections.createSynapse(activeSegment1, previousActiveCells[2], .5)
activeSegment2 = tm.createSegment(expectedWinnerCells[1])
tm.connections.createSynapse(activeSegment2, previousActiveCells[0], .5)
tm.connections.createSynapse(activeSegment2, previousActiveCells[1], .5)
tm.connections.createSynapse(activeSegment2, previousActiveCells[2], .5)
tm.compute(previousActiveColumns, False)
tm.compute(activeColumns, False)
self.assertEqual(expectedWinnerCells, tm.getWinnerCells())
示例2: testReachSegmentLimitMultipleTimes
# 需要导入模块: from nupic.algorithms.temporal_memory import TemporalMemory [as 别名]
# 或者: from nupic.algorithms.temporal_memory.TemporalMemory import createSegment [as 别名]
def testReachSegmentLimitMultipleTimes(self):
""" Hit the maxSegmentsPerCell threshold multiple times. Make sure it
works more than once.
"""
tm = TemporalMemory(
columnDimensions=[32],
cellsPerColumn=1,
activationThreshold=3,
initialPermanence=.50,
connectedPermanence=.50,
minThreshold=2,
maxNewSynapseCount=3,
permanenceIncrement=.02,
permanenceDecrement=.02,
predictedSegmentDecrement=0.0,
seed=42,
maxSegmentsPerCell=2)
tm.createSegment(10)
self.assertEqual(1, tm.connections.numSegments())
tm.createSegment(10)
self.assertEqual(2, tm.connections.numSegments())
tm.createSegment(10)
self.assertEqual(2, tm.connections.numSegments())
tm.createSegment(10)
self.assertEqual(2, tm.connections.numSegments())
示例3: testNoChangeToMatchingSegmentsInPredictedActiveColumn
# 需要导入模块: from nupic.algorithms.temporal_memory import TemporalMemory [as 别名]
# 或者: from nupic.algorithms.temporal_memory.TemporalMemory import createSegment [as 别名]
def testNoChangeToMatchingSegmentsInPredictedActiveColumn(self):
tm = TemporalMemory(
columnDimensions=[32],
cellsPerColumn=4,
activationThreshold=3,
initialPermanence=.21,
connectedPermanence=.50,
minThreshold=2,
maxNewSynapseCount=3,
permanenceIncrement=.10,
permanenceDecrement=.10,
predictedSegmentDecrement=0.0,
seed=42)
previousActiveColumns = [0]
activeColumns = [1]
previousActiveCells = [0,1,2,3]
expectedActiveCells = [4]
otherburstingCells = [5,6,7]
activeSegment = tm.createSegment(expectedActiveCells[0])
tm.connections.createSynapse(activeSegment, previousActiveCells[0], .5)
tm.connections.createSynapse(activeSegment, previousActiveCells[1], .5)
tm.connections.createSynapse(activeSegment, previousActiveCells[2], .5)
tm.connections.createSynapse(activeSegment, previousActiveCells[3], .5)
matchingSegmentOnSameCell = tm.createSegment(
expectedActiveCells[0])
s1 = tm.connections.createSynapse(matchingSegmentOnSameCell,
previousActiveCells[0], .3)
s2 = tm.connections.createSynapse(matchingSegmentOnSameCell,
previousActiveCells[1], .3)
matchingSegmentOnOtherCell = tm.createSegment(
otherburstingCells[0])
s3 = tm.connections.createSynapse(matchingSegmentOnOtherCell,
previousActiveCells[0], .3)
s4 = tm.connections.createSynapse(matchingSegmentOnOtherCell,
previousActiveCells[1], .3)
tm.compute(previousActiveColumns, True)
self.assertEqual(expectedActiveCells, tm.getPredictiveCells())
tm.compute(activeColumns, True)
self.assertAlmostEqual(.3, tm.connections.dataForSynapse(s1).permanence)
self.assertAlmostEqual(.3, tm.connections.dataForSynapse(s2).permanence)
self.assertAlmostEqual(.3, tm.connections.dataForSynapse(s3).permanence)
self.assertAlmostEqual(.3, tm.connections.dataForSynapse(s4).permanence)
示例4: testDestroySegmentsWithTooFewSynapsesToBeMatching
# 需要导入模块: from nupic.algorithms.temporal_memory import TemporalMemory [as 别名]
# 或者: from nupic.algorithms.temporal_memory.TemporalMemory import createSegment [as 别名]
def testDestroySegmentsWithTooFewSynapsesToBeMatching(self):
tm = TemporalMemory(
columnDimensions=[32],
cellsPerColumn=4,
activationThreshold=3,
initialPermanence=.2,
connectedPermanence=.50,
minThreshold=2,
maxNewSynapseCount=4,
permanenceIncrement=.10,
permanenceDecrement=.10,
predictedSegmentDecrement=0.02,
seed=42)
prevActiveColumns = [0]
prevActiveCells = [0, 1, 2, 3]
activeColumns = [2]
expectedActiveCell = 5
matchingSegment = tm.createSegment(expectedActiveCell)
tm.connections.createSynapse(matchingSegment, prevActiveCells[0], .015)
tm.connections.createSynapse(matchingSegment, prevActiveCells[1], .015)
tm.connections.createSynapse(matchingSegment, prevActiveCells[2], .015)
tm.connections.createSynapse(matchingSegment, prevActiveCells[3], .015)
tm.compute(prevActiveColumns, True)
tm.compute(activeColumns, True)
self.assertEqual(0, tm.connections.numSegments(expectedActiveCell))
示例5: testDestroyWeakSynapseOnActiveReinforce
# 需要导入模块: from nupic.algorithms.temporal_memory import TemporalMemory [as 别名]
# 或者: from nupic.algorithms.temporal_memory.TemporalMemory import createSegment [as 别名]
def testDestroyWeakSynapseOnActiveReinforce(self):
tm = TemporalMemory(
columnDimensions=[32],
cellsPerColumn=4,
activationThreshold=3,
initialPermanence=.2,
connectedPermanence=.50,
minThreshold=2,
maxNewSynapseCount=4,
permanenceIncrement=.10,
permanenceDecrement=.10,
predictedSegmentDecrement=0.02,
seed=42)
previousActiveColumns = [0]
previousActiveCells = [0, 1, 2, 3]
activeColumns = [2]
activeCell = 5
activeSegment = tm.createSegment(activeCell)
tm.connections.createSynapse(activeSegment, previousActiveCells[0], .5)
tm.connections.createSynapse(activeSegment, previousActiveCells[1], .5)
tm.connections.createSynapse(activeSegment, previousActiveCells[2], .5)
# Weak inactive synapse.
tm.connections.createSynapse(activeSegment, previousActiveCells[3], .009)
tm.compute(previousActiveColumns, True)
tm.compute(activeColumns, True)
self.assertEqual(3, tm.connections.numSynapses(activeSegment))
示例6: testMatchingSegmentAddSynapsesToAllWinnerCells
# 需要导入模块: from nupic.algorithms.temporal_memory import TemporalMemory [as 别名]
# 或者: from nupic.algorithms.temporal_memory.TemporalMemory import createSegment [as 别名]
def testMatchingSegmentAddSynapsesToAllWinnerCells(self):
tm = TemporalMemory(
columnDimensions=[32],
cellsPerColumn=1,
activationThreshold=3,
initialPermanence=.21,
connectedPermanence=.50,
minThreshold=1,
maxNewSynapseCount=3,
permanenceIncrement=.10,
permanenceDecrement=.10,
predictedSegmentDecrement=0.0,
seed=42)
previousActiveColumns = [0, 1]
prevWinnerCells = [0, 1]
activeColumns = [4]
matchingSegment = tm.createSegment(4)
tm.connections.createSynapse(matchingSegment, 0, .5)
tm.compute(previousActiveColumns, True)
self.assertEqual(prevWinnerCells, tm.getWinnerCells())
tm.compute(activeColumns)
synapses = tm.connections.synapsesForSegment(matchingSegment)
self.assertEqual(2, len(synapses))
for synapse in synapses:
synapseData = tm.connections.dataForSynapse(synapse)
if synapseData.presynapticCell != 0:
self.assertAlmostEqual(.21, synapseData.permanence)
self.assertEqual(prevWinnerCells[1], synapseData.presynapticCell)
示例7: testReinforceCorrectlyActiveSegments
# 需要导入模块: from nupic.algorithms.temporal_memory import TemporalMemory [as 别名]
# 或者: from nupic.algorithms.temporal_memory.TemporalMemory import createSegment [as 别名]
def testReinforceCorrectlyActiveSegments(self):
tm = TemporalMemory(
columnDimensions=[32],
cellsPerColumn=4,
activationThreshold=3,
initialPermanence=.2,
connectedPermanence=.50,
minThreshold=2,
maxNewSynapseCount=4,
permanenceIncrement=.10,
permanenceDecrement=.08,
predictedSegmentDecrement=0.02,
seed=42)
prevActiveColumns = [0]
prevActiveCells = [0,1,2,3]
activeColumns = [1]
activeCell = 5
activeSegment = tm.createSegment(activeCell)
as1 = tm.connections.createSynapse(activeSegment, prevActiveCells[0], .5)
as2 = tm.connections.createSynapse(activeSegment, prevActiveCells[1], .5)
as3 = tm.connections.createSynapse(activeSegment, prevActiveCells[2], .5)
is1 = tm.connections.createSynapse(activeSegment, 81, .5) #inactive synapse
tm.compute(prevActiveColumns, True)
tm.compute(activeColumns, True)
self.assertAlmostEqual(.6, tm.connections.dataForSynapse(as1).permanence)
self.assertAlmostEqual(.6, tm.connections.dataForSynapse(as2).permanence)
self.assertAlmostEqual(.6, tm.connections.dataForSynapse(as3).permanence)
self.assertAlmostEqual(.42, tm.connections.dataForSynapse(is1).permanence)
示例8: testZeroActiveColumns
# 需要导入模块: from nupic.algorithms.temporal_memory import TemporalMemory [as 别名]
# 或者: from nupic.algorithms.temporal_memory.TemporalMemory import createSegment [as 别名]
def testZeroActiveColumns(self):
tm = TemporalMemory(
columnDimensions=[32],
cellsPerColumn=4,
activationThreshold=3,
initialPermanence=.21,
connectedPermanence=.5,
minThreshold=2,
maxNewSynapseCount=3,
permanenceIncrement=.10,
permanenceDecrement=.10,
predictedSegmentDecrement=0.0,
seed=42)
previousActiveColumns = [0]
previousActiveCells = [0, 1, 2, 3]
expectedActiveCells = [4]
segment = tm.createSegment(expectedActiveCells[0])
tm.connections.createSynapse(segment, previousActiveCells[0], .5)
tm.connections.createSynapse(segment, previousActiveCells[1], .5)
tm.connections.createSynapse(segment, previousActiveCells[2], .5)
tm.connections.createSynapse(segment, previousActiveCells[3], .5)
tm.compute(previousActiveColumns, True)
self.assertFalse(len(tm.getActiveCells()) == 0)
self.assertFalse(len(tm.getWinnerCells()) == 0)
self.assertFalse(len(tm.getPredictiveCells()) == 0)
zeroColumns = []
tm.compute(zeroColumns, True)
self.assertTrue(len(tm.getActiveCells()) == 0)
self.assertTrue(len(tm.getWinnerCells()) == 0)
self.assertTrue(len(tm.getPredictiveCells()) == 0)
示例9: testPunishMatchingSegmentsInInactiveColumns
# 需要导入模块: from nupic.algorithms.temporal_memory import TemporalMemory [as 别名]
# 或者: from nupic.algorithms.temporal_memory.TemporalMemory import createSegment [as 别名]
def testPunishMatchingSegmentsInInactiveColumns(self):
tm = TemporalMemory(
columnDimensions=[32],
cellsPerColumn=4,
activationThreshold=3,
initialPermanence=.2,
connectedPermanence=.50,
minThreshold=2,
maxNewSynapseCount=4,
permanenceIncrement=.10,
permanenceDecrement=.10,
predictedSegmentDecrement=0.02,
seed=42)
previousActiveColumns = [0]
previousActiveCells = [0, 1, 2, 3]
activeColumns = [1]
previousInactiveCell = 81
activeSegment = tm.createSegment(42)
as1 = tm.connections.createSynapse(activeSegment,
previousActiveCells[0], .5)
as2 = tm.connections.createSynapse(activeSegment,
previousActiveCells[1], .5)
as3 = tm.connections.createSynapse(activeSegment,
previousActiveCells[2], .5)
is1 = tm.connections.createSynapse(activeSegment,
previousInactiveCell, .5)
matchingSegment = tm.createSegment(43)
as4 = tm.connections.createSynapse(matchingSegment,
previousActiveCells[0], .5)
as5 = tm.connections.createSynapse(matchingSegment,
previousActiveCells[1], .5)
is2 = tm.connections.createSynapse(matchingSegment,
previousInactiveCell, .5)
tm.compute(previousActiveColumns, True)
tm.compute(activeColumns, True)
self.assertAlmostEqual(.48, tm.connections.dataForSynapse(as1).permanence)
self.assertAlmostEqual(.48, tm.connections.dataForSynapse(as2).permanence)
self.assertAlmostEqual(.48, tm.connections.dataForSynapse(as3).permanence)
self.assertAlmostEqual(.48, tm.connections.dataForSynapse(as4).permanence)
self.assertAlmostEqual(.48, tm.connections.dataForSynapse(as5).permanence)
self.assertAlmostEqual(.50, tm.connections.dataForSynapse(is1).permanence)
self.assertAlmostEqual(.50, tm.connections.dataForSynapse(is2).permanence)
示例10: testReinforceSelectedMatchingSegmentInBurstingColumn
# 需要导入模块: from nupic.algorithms.temporal_memory import TemporalMemory [as 别名]
# 或者: from nupic.algorithms.temporal_memory.TemporalMemory import createSegment [as 别名]
def testReinforceSelectedMatchingSegmentInBurstingColumn(self):
tm = TemporalMemory(
columnDimensions=[32],
cellsPerColumn=4,
activationThreshold=3,
initialPermanence=.21,
connectedPermanence=.50,
minThreshold=2,
maxNewSynapseCount=3,
permanenceIncrement=.10,
permanenceDecrement=.08,
predictedSegmentDecrement=0.0,
seed=42)
previousActiveColumns = [0]
previousActiveCells = [0,1,2,3]
activeColumns = [1]
burstingCells = [4,5,6,7]
selectedMatchingSegment = tm.createSegment(burstingCells[0])
as1 = tm.connections.createSynapse(selectedMatchingSegment,
previousActiveCells[0], .3)
as2 = tm.connections.createSynapse(selectedMatchingSegment,
previousActiveCells[1], .3)
as3 = tm.connections.createSynapse(selectedMatchingSegment,
previousActiveCells[2], .3)
is1 = tm.connections.createSynapse(selectedMatchingSegment, 81, .3)
otherMatchingSegment = tm.createSegment(burstingCells[1])
tm.connections.createSynapse(otherMatchingSegment,
previousActiveCells[0], .3)
tm.connections.createSynapse(otherMatchingSegment,
previousActiveCells[1], .3)
tm.connections.createSynapse(otherMatchingSegment, 81, .3)
tm.compute(previousActiveColumns, True)
tm.compute(activeColumns, True)
self.assertAlmostEqual(.4, tm.connections.dataForSynapse(as1).permanence)
self.assertAlmostEqual(.4, tm.connections.dataForSynapse(as2).permanence)
self.assertAlmostEqual(.4, tm.connections.dataForSynapse(as3).permanence)
self.assertAlmostEqual(.22, tm.connections.dataForSynapse(is1).permanence)
示例11: testDestroySegmentsThenReachLimit
# 需要导入模块: from nupic.algorithms.temporal_memory import TemporalMemory [as 别名]
# 或者: from nupic.algorithms.temporal_memory.TemporalMemory import createSegment [as 别名]
def testDestroySegmentsThenReachLimit(self):
""" Destroy some segments then verify that the maxSegmentsPerCell is still
correctly applied.
"""
tm = TemporalMemory(
columnDimensions=[32],
cellsPerColumn=1,
activationThreshold=3,
initialPermanence=.50,
connectedPermanence=.50,
minThreshold=2,
maxNewSynapseCount=3,
permanenceIncrement=.02,
permanenceDecrement=.02,
predictedSegmentDecrement=0.0,
seed=42,
maxSegmentsPerCell=2)
segment1 = tm.createSegment(11)
segment2 = tm.createSegment(11)
self.assertEqual(2, tm.connections.numSegments())
tm.connections.destroySegment(segment1)
tm.connections.destroySegment(segment2)
self.assertEqual(0, tm.connections.numSegments())
tm.createSegment(11)
self.assertEqual(1, tm.connections.numSegments())
tm.createSegment(11)
self.assertEqual(2, tm.connections.numSegments())
segment3 = tm.createSegment(11)
self.assertEqual(2, tm.connections.numSegments(11))
self.assertEqual(2, tm.connections.numSegments())
示例12: testConnectionsNeverChangeWhenLearningDisabled
# 需要导入模块: from nupic.algorithms.temporal_memory import TemporalMemory [as 别名]
# 或者: from nupic.algorithms.temporal_memory.TemporalMemory import createSegment [as 别名]
def testConnectionsNeverChangeWhenLearningDisabled(self):
tm = TemporalMemory(
columnDimensions=[32],
cellsPerColumn=4,
activationThreshold=3,
initialPermanence=.2,
connectedPermanence=.50,
minThreshold=2,
maxNewSynapseCount=4,
permanenceIncrement=.10,
permanenceDecrement=.10,
predictedSegmentDecrement=0.02,
seed=42)
prevActiveColumns = [0]
prevActiveCells = [0, 1, 2, 3]
activeColumns = [1, 2] #1 is predicted, 2 is bursting
prevInactiveCell = 81
expectedActiveCells = [4]
correctActiveSegment = tm.createSegment(expectedActiveCells[0])
tm.connections.createSynapse(correctActiveSegment, prevActiveCells[0], .5)
tm.connections.createSynapse(correctActiveSegment, prevActiveCells[1], .5)
tm.connections.createSynapse(correctActiveSegment, prevActiveCells[2], .5)
wrongMatchingSegment = tm.createSegment(43)
tm.connections.createSynapse(wrongMatchingSegment, prevActiveCells[0], .5)
tm.connections.createSynapse(wrongMatchingSegment, prevActiveCells[1], .5)
tm.connections.createSynapse(wrongMatchingSegment, prevInactiveCell, .5)
before = copy.deepcopy(tm.connections)
tm.compute(prevActiveColumns, False)
tm.compute(activeColumns, False)
self.assertEqual(before, tm.connections)
示例13: testRecycleWeakestSynapseToMakeRoomForNewSynapse
# 需要导入模块: from nupic.algorithms.temporal_memory import TemporalMemory [as 别名]
# 或者: from nupic.algorithms.temporal_memory.TemporalMemory import createSegment [as 别名]
def testRecycleWeakestSynapseToMakeRoomForNewSynapse(self):
tm = TemporalMemory(
columnDimensions=[32],
cellsPerColumn=1,
activationThreshold=3,
initialPermanence=.21,
connectedPermanence=.50,
minThreshold=1,
maxNewSynapseCount=3,
permanenceIncrement=.02,
permanenceDecrement=.02,
predictedSegmentDecrement=0.0,
seed=42,
maxSynapsesPerSegment=4)
prevActiveColumns = [1, 2, 3]
prevWinnerCells = [1, 2, 3]
activeColumns = [4]
matchingSegment = tm.createSegment(4)
tm.connections.createSynapse(matchingSegment, 81, .6)
# Create a weak synapse. Make sure it's not so weak that permanenceIncrement
# destroys it.
tm.connections.createSynapse(matchingSegment, 0, .11)
# Create a synapse that will match.
tm.connections.createSynapse(matchingSegment, 1, .20)
# Create a synapse with a high permanence
tm.connections.createSynapse(matchingSegment, 31, .60)
tm.compute(prevActiveColumns)
self.assertEqual(prevWinnerCells, tm.getWinnerCells())
tm.compute(activeColumns)
synapses = tm.connections.synapsesForSegment(matchingSegment)
self.assertEqual(4, len(synapses))
presynapticCells = set(synapse.presynapticCell for synapse in synapses)
self.assertEqual(set([1, 2, 3, 31]), presynapticCells)
示例14: testActiveSegmentGrowSynapsesAccordingToPotentialOverlap
# 需要导入模块: from nupic.algorithms.temporal_memory import TemporalMemory [as 别名]
# 或者: from nupic.algorithms.temporal_memory.TemporalMemory import createSegment [as 别名]
def testActiveSegmentGrowSynapsesAccordingToPotentialOverlap(self):
"""
When a segment becomes active, grow synapses to previous winner cells.
The number of grown synapses is calculated from the "matching segment"
overlap, not the "active segment" overlap.
"""
tm = TemporalMemory(
columnDimensions=[32],
cellsPerColumn=1,
activationThreshold=2,
initialPermanence=.21,
connectedPermanence=.50,
minThreshold=1,
maxNewSynapseCount=4,
permanenceIncrement=.10,
permanenceDecrement=.10,
predictedSegmentDecrement=0.0,
seed=42)
# Use 1 cell per column so that we have easy control over the winner cells.
previousActiveColumns = [0, 1, 2, 3, 4]
prevWinnerCells = [0, 1, 2, 3, 4]
activeColumns = [5]
activeSegment = tm.createSegment(5)
tm.connections.createSynapse(activeSegment, 0, .5)
tm.connections.createSynapse(activeSegment, 1, .5)
tm.connections.createSynapse(activeSegment, 2, .2)
tm.compute(previousActiveColumns, True)
self.assertEqual(prevWinnerCells, tm.getWinnerCells())
tm.compute(activeColumns, True)
presynapticCells = set(synapse.presynapticCell for synapse in
tm.connections.synapsesForSegment(activeSegment))
self.assertTrue(presynapticCells == set([0, 1, 2, 3]) or
presynapticCells == set([0, 1, 2, 4]))
示例15: testAddSegmentToCellWithFewestSegments
# 需要导入模块: from nupic.algorithms.temporal_memory import TemporalMemory [as 别名]
# 或者: from nupic.algorithms.temporal_memory.TemporalMemory import createSegment [as 别名]
def testAddSegmentToCellWithFewestSegments(self):
grewOnCell1 = False
grewOnCell2 = False
for seed in xrange(100):
tm = TemporalMemory(
columnDimensions=[32],
cellsPerColumn=4,
activationThreshold=3,
initialPermanence=.2,
connectedPermanence=.50,
minThreshold=2,
maxNewSynapseCount=4,
permanenceIncrement=.10,
permanenceDecrement=.10,
predictedSegmentDecrement=0.02,
seed=seed)
prevActiveColumns = [1, 2, 3, 4]
activeColumns = [0]
prevActiveCells = [4, 5, 6, 7]
nonMatchingCells = [0, 3]
activeCells = [0, 1, 2, 3]
segment1 = tm.createSegment(nonMatchingCells[0])
tm.connections.createSynapse(segment1, prevActiveCells[0], .5)
segment2 = tm.createSegment(nonMatchingCells[1])
tm.connections.createSynapse(segment2, prevActiveCells[1], .5)
tm.compute(prevActiveColumns, True)
tm.compute(activeColumns, True)
self.assertEqual(activeCells, tm.getActiveCells())
self.assertEqual(3, tm.connections.numSegments())
self.assertEqual(1, tm.connections.numSegments(0))
self.assertEqual(1, tm.connections.numSegments(3))
self.assertEqual(1, tm.connections.numSynapses(segment1))
self.assertEqual(1, tm.connections.numSynapses(segment2))
segments = list(tm.connections.segmentsForCell(1))
if len(segments) == 0:
segments2 = list(tm.connections.segmentsForCell(2))
self.assertFalse(len(segments2) == 0)
grewOnCell2 = True
segments.append(segments2[0])
else:
grewOnCell1 = True
self.assertEqual(1, len(segments))
synapses = list(tm.connections.synapsesForSegment(segments[0]))
self.assertEqual(4, len(synapses))
columnChecklist = set(prevActiveColumns)
for synapse in synapses:
synapseData = tm.connections.dataForSynapse(synapse)
self.assertAlmostEqual(.2, synapseData.permanence)
column = tm.columnForCell(synapseData.presynapticCell)
self.assertTrue(column in columnChecklist)
columnChecklist.remove(column)
self.assertTrue(len(columnChecklist) == 0)
self.assertTrue(grewOnCell1)
self.assertTrue(grewOnCell2)