当前位置: 首页>>代码示例>>Python>>正文


Python TemporalMemory.reset方法代码示例

本文整理汇总了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))
开发者ID:Erichy94,项目名称:nupic,代码行数:50,代码来源:temporal_memory_test.py

示例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()
开发者ID:dubing12,项目名称:nupic.nlp-examples,代码行数:49,代码来源:nupic_words.py

示例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.
开发者ID:Erichy94,项目名称:nupic,代码行数:33,代码来源:hello_tm.py


注:本文中的nupic.algorithms.temporal_memory.TemporalMemory.reset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。