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


Python Connections.cellForSegment方法代码示例

本文整理汇总了Python中nupic.research.connections.Connections.cellForSegment方法的典型用法代码示例。如果您正苦于以下问题:Python Connections.cellForSegment方法的具体用法?Python Connections.cellForSegment怎么用?Python Connections.cellForSegment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nupic.research.connections.Connections的用法示例。


在下文中一共展示了Connections.cellForSegment方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TemporalMemory

# 需要导入模块: from nupic.research.connections import Connections [as 别名]
# 或者: from nupic.research.connections.Connections import cellForSegment [as 别名]

#.........这里部分代码省略.........
                      prevActiveCells,
                      winnerCells,
                      prevWinnerCells,
                      predictedInactiveCells,
                      prevMatchingSegments):
    """
    Phase 3: Perform learning by adapting segments.

    Pseudocode:

      - (learning) for each prev active or learning segment
        - if learning segment or from winner cell
          - strengthen active synapses
          - weaken inactive synapses
        - if learning segment
          - add some synapses to the segment
            - subsample from prev winner cells

      - if predictedSegmentDecrement > 0
        - for each previously matching segment
          - if cell is a predicted inactive cell
            - weaken active synapses but don't touch inactive synapses

    @param prevActiveSegments           (set)         Indices of active segments in `t-1`
    @param learningSegments             (set)         Indices of learning segments in `t`
    @param prevActiveCells              (set)         Indices of active cells in `t-1`
    @param winnerCells                  (set)         Indices of winner cells in `t`
    @param prevWinnerCells              (set)         Indices of winner cells in `t-1`
    @param predictedInactiveCells       (set)         Indices of predicted inactive cells
    @param prevMatchingSegments         (set)         Indices of segments with
    """
    for segment in prevActiveSegments | learningSegments:
      isLearningSegment = segment in learningSegments
      isFromWinnerCell = self.connections.cellForSegment(segment) in winnerCells

      activeSynapses = self.activeSynapsesForSegment(segment, prevActiveCells)

      if isLearningSegment or isFromWinnerCell:
        self.adaptSegment(segment,
                          activeSynapses,
                          self.permanenceIncrement,
                          self.permanenceDecrement)

      if isLearningSegment:
        n = self.maxNewSynapseCount - len(activeSynapses)

        for presynapticCell in self.pickCellsToLearnOn(n,
                                                       segment,
                                                       prevWinnerCells):
          self.connections.createSynapse(segment,
                                         presynapticCell,
                                         self.initialPermanence)

    if self.predictedSegmentDecrement > 0:
      for segment in prevMatchingSegments:
        isPredictedInactiveCell = (self.connections.cellForSegment(segment) in
                                   predictedInactiveCells)
        activeSynapses = self.activeSynapsesForSegment(segment, prevActiveCells)

        if isPredictedInactiveCell:
          self.adaptSegment(segment,
                            activeSynapses,
                            -self.predictedSegmentDecrement,
                            0.0)

开发者ID:GeraldLoeffler,项目名称:nupic,代码行数:68,代码来源:temporal_memory.py

示例2: TemporalMemory

# 需要导入模块: from nupic.research.connections import Connections [as 别名]
# 或者: from nupic.research.connections.Connections import cellForSegment [as 别名]

#.........这里部分代码省略.........

  @staticmethod
  def activatePredictedColumn(connections, excitedColumn, learn,
                              permanenceDecrement, permanenceIncrement,
                              prevActiveCells):
    """ Determines which cells in a predicted column should be added to
    winner cells list and calls adaptSegment on the segments that correctly
    predicted this column.

    @param connections     (Object) Connections instance for the tm
    @param excitedColumn   (dict)   Dict generated by excitedColumnsGenerator
    @param learn           (bool)   Determines if permanences are adjusted
    @permanenceDecrement   (float)  Amount by which permanences of synapses are
                                    decremented during learning.
    @permanenceIncrement   (float)  Amount by which permanences of synapses are
                                    incremented during learning.
    @param prevActiveCells (list)   Active cells in `t-1`

    @return cellsToAdd (list) A list of predicted cells that will be added to
                              active cells and winner cells.
                              
    Pseudocode:
    for each cell in the column that has an active distal dendrite segment
      mark the cell as active
      mark the cell as a winner cell
      (learning) for each active distal dendrite segment
        strengthen active synapses
        weaken inactive synapses
    """

    cellsToAdd = []
    cell = None
    for active in excitedColumn["activeSegments"]:
      newCell = not cell == connections.cellForSegment(active)
      if newCell:
        cell = connections.cellForSegment(active)
        cellsToAdd.append(cell)

      if learn:
        TemporalMemory.adaptSegment(connections, prevActiveCells,
                                    permanenceIncrement, permanenceDecrement,
                                    active)

    return cellsToAdd


  @staticmethod
  def burstColumn(cellsPerColumn, connections, excitedColumn,
                  learn, initialPermanence, maxNewSynapseCount,
                  permanenceDecrement, permanenceIncrement,
                  prevActiveCells, prevWinnerCells, random):
    """ Activates all of the cells in an unpredicted active column,
    chooses a winner cell, and, if learning is turned on, either adapts or
    creates a segment. growSynapses is invoked on this segment.

    @param cellsPerColumn      (int)    Number of cells per column
    @param connections         (Object) Connections instance for the tm
    @param excitedColumn       (dict)   Excited Column instance from
                                        excitedColumnsGenerator
    @param learn               (bool)   Whether or not learning is enabled
    @param initialPermanence   (float)  Initial permanence of a new synapse.
    @param maxNewSynapseCount  (int)    The maximum number of synapses added to
                                        a segment during learning
    @param permanenceDecrement (float)  Amount by which permanences of synapses
                                        are decremented during learning
    @param permanenceIncrement (float)  Amount by which permanences of synapses
开发者ID:GYGit,项目名称:nupic,代码行数:70,代码来源:temporal_memory.py


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