本文整理汇总了Python中nupic.algorithms.temporal_memory.TemporalMemory.columnForCell方法的典型用法代码示例。如果您正苦于以下问题:Python TemporalMemory.columnForCell方法的具体用法?Python TemporalMemory.columnForCell怎么用?Python TemporalMemory.columnForCell使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nupic.algorithms.temporal_memory.TemporalMemory
的用法示例。
在下文中一共展示了TemporalMemory.columnForCell方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testColumnForCell1D
# 需要导入模块: from nupic.algorithms.temporal_memory import TemporalMemory [as 别名]
# 或者: from nupic.algorithms.temporal_memory.TemporalMemory import columnForCell [as 别名]
def testColumnForCell1D(self):
tm = TemporalMemory(
columnDimensions=[2048],
cellsPerColumn=5
)
self.assertEqual(tm.columnForCell(0), 0)
self.assertEqual(tm.columnForCell(4), 0)
self.assertEqual(tm.columnForCell(5), 1)
self.assertEqual(tm.columnForCell(10239), 2047)
示例2: testColumnForCell2D
# 需要导入模块: from nupic.algorithms.temporal_memory import TemporalMemory [as 别名]
# 或者: from nupic.algorithms.temporal_memory.TemporalMemory import columnForCell [as 别名]
def testColumnForCell2D(self):
tm = TemporalMemory(
columnDimensions=[64, 64],
cellsPerColumn=4
)
self.assertEqual(tm.columnForCell(0), 0)
self.assertEqual(tm.columnForCell(3), 0)
self.assertEqual(tm.columnForCell(4), 1)
self.assertEqual(tm.columnForCell(16383), 4095)
示例3: testColumnForCellInvalidCell
# 需要导入模块: from nupic.algorithms.temporal_memory import TemporalMemory [as 别名]
# 或者: from nupic.algorithms.temporal_memory.TemporalMemory import columnForCell [as 别名]
def testColumnForCellInvalidCell(self):
tm = TemporalMemory(
columnDimensions=[64, 64],
cellsPerColumn=4
)
try:
tm.columnForCell(16383)
except IndexError:
self.fail("IndexError raised unexpectedly")
args = [16384]
self.assertRaises(IndexError, tm.columnForCell, *args)
args = [-1]
self.assertRaises(IndexError, tm.columnForCell, *args)
示例4: print
# 需要导入模块: from nupic.algorithms.temporal_memory import TemporalMemory [as 别名]
# 或者: from nupic.algorithms.temporal_memory.TemporalMemory import columnForCell [as 别名]
tm.compute(activeColumns, learn = False)
# The following print statements prints out the active cells, predictive
# cells, active segments and winner cells.
#
# What you should notice is that the columns where active state is 1
# represent the SDR for the current input pattern and the columns where
# predicted state is 1 represent the SDR for the next expected pattern
print "\nAll the active and predicted cells:"
print("active cells " + str(tm.getActiveCells()))
print("predictive cells " + str(tm.getPredictiveCells()))
print("winner cells " + str(tm.getWinnerCells()))
print("# of active segments " + str(tm.connections.numSegments()))
activeColumnsIndeces = [tm.columnForCell(i) for i in tm.getActiveCells()]
predictedColumnIndeces = [tm.columnForCell(i) for i in tm.getPredictiveCells()]
# Reconstructing the active and inactive columns with 1 as active and 0 as
# inactive representation.
actColState = ['1' if i in activeColumnsIndeces else '0' for i in range(tm.numberOfColumns())]
actColStr = ("".join(actColState))
predColState = ['1' if i in predictedColumnIndeces else '0' for i in range(tm.numberOfColumns())]
predColStr = ("".join(predColState))
# For convenience the cells are grouped
# 10 at a time. When there are multiple cells per column the printout
# is arranged so the cells in a column are stacked together
print "Active columns: " + formatRow(actColStr)
示例5: testAddSegmentToCellWithFewestSegments
# 需要导入模块: from nupic.algorithms.temporal_memory import TemporalMemory [as 别名]
# 或者: from nupic.algorithms.temporal_memory.TemporalMemory import columnForCell [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)