本文整理汇总了Python中nupic.algorithms.temporal_memory.TemporalMemory.reset方法的典型用法代码示例。如果您正苦于以下问题:Python TemporalMemory.reset方法的具体用法?Python TemporalMemory.reset怎么用?Python TemporalMemory.reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nupic.algorithms.temporal_memory.TemporalMemory
的用法示例。
在下文中一共展示了TemporalMemory.reset方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testRecycleLeastRecentlyActiveSegmentToMakeRoomForNewSegment
# 需要导入模块: from nupic.algorithms.temporal_memory import TemporalMemory [as 别名]
# 或者: from nupic.algorithms.temporal_memory.TemporalMemory import reset [as 别名]
def testRecycleLeastRecentlyActiveSegmentToMakeRoomForNewSegment(self):
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)
prevActiveColumns1 = [0, 1, 2]
prevActiveColumns2 = [3, 4, 5]
prevActiveColumns3 = [6, 7, 8]
activeColumns = [9]
tm.compute(prevActiveColumns1)
tm.compute(activeColumns)
self.assertEqual(1, tm.connections.numSegments(9))
oldestSegment = list(tm.connections.segmentsForCell(9))[0]
tm.reset()
tm.compute(prevActiveColumns2)
tm.compute(activeColumns)
self.assertEqual(2, tm.connections.numSegments(9))
oldPresynaptic = \
set(synapse.presynapticCell
for synapse in tm.connections.synapsesForSegment(oldestSegment))
tm.reset()
tm.compute(prevActiveColumns3)
tm.compute(activeColumns)
self.assertEqual(2, tm.connections.numSegments(9))
# Verify none of the segments are connected to the cells the old
# segment was connected to.
for segment in tm.connections.segmentsForCell(9):
newPresynaptic = set(synapse.presynapticCell
for synapse
in tm.connections.synapsesForSegment(segment))
self.assertEqual([], list(oldPresynaptic & newPresynaptic))
示例2: Client
# 需要导入模块: from nupic.algorithms.temporal_memory import TemporalMemory [as 别名]
# 或者: from nupic.algorithms.temporal_memory.TemporalMemory import reset [as 别名]
class Client(object):
def __init__(self,
numberOfCols=16384,
cellsPerColumn=8,
activationThreshold=60,
minThreshold=60,
verbosity=0
):
self.tm = TM(
columnDimensions=(numberOfCols,),
cellsPerColumn=cellsPerColumn,
activationThreshold=activationThreshold,
minThreshold=minThreshold,
maxNewSynapseCount=164,
initialPermanence=0.21,
connectedPermanence=0.3,
permanenceIncrement=0.1,
permanenceDecrement=0.0,
predictedSegmentDecrement=0.0,
)
if verbosity > 0:
print "TM Params:"
print "columnDimensions: {}".format(self.tm.getColumnDimensions())
print "cellsPerColumn: {}".format(self.tm.getCellsPerColumn())
print "activationThreshold: {}".format(self.tm.getActivationThreshold())
print "minThreshold: {}".format(self.tm.getMinThreshold())
print "maxNewSynapseCount {}".format(self.tm.getMaxNewSynapseCount())
print "initialPermanence {}".format(self.tm.getInitialPermanence())
print "connectedPermanence {}".format(self.tm.getConnectedPermanence())
print "permanenceIncrement {}".format(self.tm.getPermanenceIncrement())
print "permanenceDecrement {}".format(self.tm.getPermanenceDecrement())
print "predictedSegmentDecrement {}".format(self.tm.getPredictedSegmentDecrement())
def feed(self, sdr, learn=True):
tm = self.tm
narr = numpy.array(sdr, dtype="uint32")
tm.compute(narr, learn=learn)
# This returns the indices of the predictive minicolumns.
predictiveCells = tm.getPredictiveCells()
return numpy.unique(numpy.array(predictiveCells) / tm.getCellsPerColumn())
def reset(self):
self.tm.reset()
示例3: want
# 需要导入模块: from nupic.algorithms.temporal_memory import TemporalMemory [as 别名]
# 或者: from nupic.algorithms.temporal_memory.TemporalMemory import reset [as 别名]
# The compute method performs one step of learning and/or inference. Note:
# here we just perform learning but you can perform prediction/inference and
# learning in the same step if you want (online learning).
tm.compute(activeColumns, learn = True)
# The following print statements can be ignored.
# Useful for tracing internal states
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()))
# The reset command tells the TM that a sequence just ended and essentially
# zeros out all the states. It is not strictly necessary but it's a bit
# messier without resets, and the TM learns quicker with resets.
tm.reset()
#######################################################################
#
# Step 3: send the same sequence of vectors and look at predictions made by
# temporal memory
for j in range(5):
print "\n\n--------","ABCDE"[j],"-----------"
print "Raw input vector : " + formatRow(x[j])
activeColumns = set([i for i, j in zip(count(), x[j]) if j == 1])
# Send each vector to the TM, with learning turned off
tm.compute(activeColumns, learn = False)
# The following print statements prints out the active cells, predictive
# cells, active segments and winner cells.