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


Python Connections.destroySynapse方法代码示例

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


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

示例1: testPathsNotInvalidatedByOtherDestroys

# 需要导入模块: from nupic.research.connections import Connections [as 别名]
# 或者: from nupic.research.connections.Connections import destroySynapse [as 别名]
  def testPathsNotInvalidatedByOtherDestroys(self):
    """ Creates segments and synapses, then destroys segments and synapses on
        either side of them and verifies that existing Segment and Synapse
        instances still point to the same segment / synapse as before.
    """
    connections = Connections(1024)
    segment1 = connections.createSegment(11)
    connections.createSegment(12)
    segment3 = connections.createSegment(13)
    connections.createSegment(14)
    segment5 = connections.createSegment(15)

    synapse1 = connections.createSynapse(segment3, 201, .85)
    synapse2 = connections.createSynapse(segment3, 202, .85)
    synapse3 = connections.createSynapse(segment3, 203, .85)
    synapse4 = connections.createSynapse(segment3, 204, .85)
    synapse5 = connections.createSynapse(segment3, 205, .85)

    self.assertEqual(203, synapse3.presynapticCell)
    connections.destroySynapse(synapse1)
    self.assertEqual(203, synapse3.presynapticCell)
    connections.destroySynapse(synapse5)
    self.assertEqual(203, synapse3.presynapticCell)

    connections.destroySegment(segment1)
    self.assertEqual(set([synapse2, synapse3, synapse4]),
                     connections.synapsesForSegment(segment3))
    connections.destroySegment(segment5)
    self.assertEqual(set([synapse2, synapse3, synapse4]),
                     connections.synapsesForSegment(segment3))
    self.assertEqual(203, synapse3.presynapticCell)
开发者ID:blueburningcoder,项目名称:nupic,代码行数:33,代码来源:connections_test.py

示例2: testDestroySynapsesThenReachLimit

# 需要导入模块: from nupic.research.connections import Connections [as 别名]
# 或者: from nupic.research.connections.Connections import destroySynapse [as 别名]
  def testDestroySynapsesThenReachLimit(self):
    """ Destroy some synapses then verify that the maxSynapsesPerSegment is
        still correctly applied.
    """
    connections = Connections(1024, 2, 2)

    segment = connections.createSegment(10)

    synapse1 = connections.createSynapse(segment, 201, .85)
    synapse2 = connections.createSynapse(segment, 202, .85)

    self.assertEqual(2, connections.numSynapses())
    connections.destroySynapse(synapse1)
    connections.destroySynapse(synapse2)
    self.assertEqual(0, connections.numSynapses())

    connections.createSynapse(segment, 201, .85)
    self.assertEqual(1, connections.numSynapses())
    connections.createSynapse(segment, 202, .90)
    self.assertEqual(2, connections.numSynapses())
    synapse3 = connections.createSynapse(segment, 203, .8)
    self.assertEqual(2, connections.numSynapses())
开发者ID:blueburningcoder,项目名称:nupic,代码行数:24,代码来源:connections_test.py

示例3: testReuseSegmentWithDestroyedSynapses

# 需要导入模块: from nupic.research.connections import Connections [as 别名]
# 或者: from nupic.research.connections.Connections import destroySynapse [as 别名]
  def testReuseSegmentWithDestroyedSynapses(self):
    """ Destroy a segment that has a destroyed synapse and a non-destroyed
        synapse. Create a new segment in the same place. Make sure its synapse
        count is correct.
    """
    connections = Connections(1024)

    segment = connections.createSegment(11)

    synapse1 = connections.createSynapse(segment, 201, .85)
    connections.createSynapse(segment, 202, .85)

    connections.destroySynapse(synapse1)

    self.assertEqual(1, connections.numSynapses(segment))

    connections.destroySegment(segment)

    reincarnated = connections.createSegment(11)

    self.assertEqual(0, connections.numSynapses(reincarnated))
    self.assertEqual(0, len(connections.synapsesForSegment(reincarnated)))
开发者ID:blueburningcoder,项目名称:nupic,代码行数:24,代码来源:connections_test.py

示例4: testDestroySynapse

# 需要导入模块: from nupic.research.connections import Connections [as 别名]
# 或者: from nupic.research.connections.Connections import destroySynapse [as 别名]
  def testDestroySynapse(self):
    """ Creates a segment, creates a number of synapses on it, destroys a
        synapse, and makes sure it got destroyed.
    """
    connections = Connections(1024)

    segment = connections.createSegment(20)
    synapse1 = connections.createSynapse(segment, 80, .85)
    synapse2 = connections.createSynapse(segment, 81, .85)
    synapse3 = connections.createSynapse(segment, 82, .15)

    self.assertEqual(3, connections.numSynapses())

    connections.destroySynapse(synapse2)

    self.assertEqual(2, connections.numSynapses())
    self.assertEqual(connections.synapsesForSegment(segment), [synapse1,
                                                               synapse3])
    active, matching = connections.computeActivity([80, 81, 82], .5, 2, 0.0, 1)
    self.assertEqual(0, len(active))
    self.assertEqual(1, len(matching))
    self.assertEqual(2, matching[0].overlap)
开发者ID:andrewmalta13,项目名称:nupic,代码行数:24,代码来源:connections_test.py

示例5: testDestroySynapse

# 需要导入模块: from nupic.research.connections import Connections [as 别名]
# 或者: from nupic.research.connections.Connections import destroySynapse [as 别名]
  def testDestroySynapse(self):
    """ Creates a segment, creates a number of synapses on it, destroys a
        synapse, and makes sure it got destroyed.
    """
    connections = Connections(1024)

    segment = connections.createSegment(20)
    synapse1 = connections.createSynapse(segment, 80, .85)
    synapse2 = connections.createSynapse(segment, 81, .85)
    synapse3 = connections.createSynapse(segment, 82, .15)

    self.assertEqual(3, connections.numSynapses())

    connections.destroySynapse(synapse2)

    self.assertEqual(2, connections.numSynapses())
    self.assertEqual(set([synapse1, synapse3]),
                     connections.synapsesForSegment(segment))
    (numActiveConnected,
     numActivePotential) = connections.computeActivity([80, 81, 82], .5)

    self.assertEqual(1, numActiveConnected[segment.flatIdx])
    self.assertEqual(2, numActivePotential[segment.flatIdx])
开发者ID:blueburningcoder,项目名称:nupic,代码行数:25,代码来源:connections_test.py

示例6: testDestroySegmentWithDestroyedSynapses

# 需要导入模块: from nupic.research.connections import Connections [as 别名]
# 或者: from nupic.research.connections.Connections import destroySynapse [as 别名]
  def testDestroySegmentWithDestroyedSynapses(self):
    """ Destroy a segment that has a destroyed synapse and a non-destroyed
        synapse. Make sure nothing gets double-destroyed.
    """
    connections = Connections(1024)

    segment1 = connections.createSegment(11)
    segment2 = connections.createSegment(12)

    connections.createSynapse(segment1, 101, .85)
    synapse2a = connections.createSynapse(segment2, 201, .85)
    connections.createSynapse(segment2, 202, .85)

    self.assertEqual(3, connections.numSynapses())

    connections.destroySynapse(synapse2a)

    self.assertEqual(2, connections.numSegments())
    self.assertEqual(2, connections.numSynapses())

    connections.destroySegment(segment2)

    self.assertEqual(1, connections.numSegments())
    self.assertEqual(1, connections.numSynapses())
开发者ID:blueburningcoder,项目名称:nupic,代码行数:26,代码来源:connections_test.py

示例7: TemporalMemory

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

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

      if synapseData.presynapticCell in activeCells:
        synapses.add(synapse)

    return synapses


  def adaptSegment(self, segment, activeSynapses,
                   permanenceIncrement, permanenceDecrement):
    """
    Updates synapses on segment.
    Strengthens active synapses; weakens inactive synapses.

    @param segment              (int)    Segment index
    @param activeSynapses       (set)    Indices of active synapses
    @param permanenceIncrement  (float)  Amount to increment active synapses
    @param permanenceDecrement  (float)  Amount to decrement inactive synapses
    """
    # Need to copy synapses for segment set below because it will be modified
    # during iteration by `destroySynapse`
    for synapse in set(self.connections.synapsesForSegment(segment)):
      synapseData = self.connections.dataForSynapse(synapse)
      permanence = synapseData.permanence

      if synapse in activeSynapses:
        permanence += permanenceIncrement
      else:
        permanence -= permanenceDecrement

      # Keep permanence within min/max bounds
      permanence = max(0.0, min(1.0, permanence))

      if (abs(permanence) < EPSILON):
        self.connections.destroySynapse(synapse)
      else:
        self.connections.updateSynapsePermanence(synapse, permanence)


  def pickCellsToLearnOn(self, n, segment, winnerCells):
    """
    Pick cells to form distal connections to.

    TODO: Respect topology and learningRadius

    @param n           (int) Number of cells to pick
    @param segment     (int) Segment index
    @param winnerCells (set) Indices of winner cells in `t`

    @return (set) Indices of cells picked
    """
    candidates = set(winnerCells)

    # Remove cells that are already synapsed on by this segment
    for synapse in self.connections.synapsesForSegment(segment):
      synapseData = self.connections.dataForSynapse(synapse)
      presynapticCell = synapseData.presynapticCell

      if presynapticCell in candidates:
        candidates.remove(presynapticCell)

    n = min(n, len(candidates))
    candidates = sorted(candidates)
    cells = set()

    # Pick n cells randomly
    for _ in range(n):
开发者ID:GeraldLoeffler,项目名称:nupic,代码行数:70,代码来源:temporal_memory.py


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