本文整理汇总了Python中nupic.research.connections.Connections.startNewIteration方法的典型用法代码示例。如果您正苦于以下问题:Python Connections.startNewIteration方法的具体用法?Python Connections.startNewIteration怎么用?Python Connections.startNewIteration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nupic.research.connections.Connections
的用法示例。
在下文中一共展示了Connections.startNewIteration方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testCreateSegmentReuse
# 需要导入模块: from nupic.research.connections import Connections [as 别名]
# 或者: from nupic.research.connections.Connections import startNewIteration [as 别名]
def testCreateSegmentReuse(self):
connections = Connections(1024, 2)
segment1 = connections.createSegment(42)
connections.createSynapse(segment1, 1, .5)
connections.createSynapse(segment1, 2, .5)
# Let some time pass.
connections.startNewIteration();
connections.startNewIteration();
connections.startNewIteration();
# Create a segment with 3 synapse.
segment2 = connections.createSegment(42)
connections.createSynapse(segment2, 1, .5)
connections.createSynapse(segment2, 2, .5)
connections.createSynapse(segment2, 3, .5)
connections.startNewIteration();
# Give the first segment some activity.
connections.recordSegmentActivity(segment1)
# Create a new segment with 1 synapse.
segment3 = connections.createSegment(42);
connections.createSynapse(segment3, 1, .5)
segments = connections.segmentsForCell(42)
self.assertEqual(2, len(segments))
# Verify first segment is still there with the same synapses.
self.assertEqual(set([1, 2]),
set(synapse.presynapticCell for synapse in
connections.synapsesForSegment(segments[0])))
# Verify second segment has been replaced.
self.assertEqual(set([1]),
set(synapse.presynapticCell for synapse in
connections.synapsesForSegment(segments[1])))
# Verify the flatIdxs were properly reused.
self.assertLess(segment1.flatIdx, 2)
self.assertLess(segment3.flatIdx, 2)
self.assertTrue(segment1 is connections.segmentForFlatIdx(segment1.flatIdx))
self.assertTrue(segment3 is connections.segmentForFlatIdx(segment3.flatIdx))