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


Python SpatialPooler._potentialPools方法代码示例

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


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

示例1: testBumpUpWeakColumns

# 需要导入模块: from nupic.research.spatial_pooler import SpatialPooler [as 别名]
# 或者: from nupic.research.spatial_pooler.SpatialPooler import _potentialPools [as 别名]
  def testBumpUpWeakColumns(self):
    sp = SpatialPooler(inputDimensions=[8],
                      columnDimensions=[5])

    sp._synPermBelowStimulusInc = 0.01
    sp._synPermTrimThreshold = 0.05
    sp._overlapDutyCycles = numpy.array([0, 0.009, 0.1, 0.001, 0.002])
    sp._minOverlapDutyCycles = numpy.array(5*[0.01])

    sp._potentialPools = SparseBinaryMatrix(
       [[1, 1, 1, 1, 0, 0, 0, 0],
        [1, 0, 0, 0, 1, 1, 0, 1],
        [0, 0, 1, 0, 1, 1, 1, 0],
        [1, 1, 1, 0, 0, 0, 1, 0],
        [1, 1, 1, 1, 1, 1, 1, 1]])

    sp._permanences = SparseMatrix(
      [[0.200, 0.120, 0.090, 0.040, 0.000, 0.000, 0.000, 0.000],
       [0.150, 0.000, 0.000, 0.000, 0.180, 0.120, 0.000, 0.450],
       [0.000, 0.000, 0.014, 0.000, 0.032, 0.044, 0.110, 0.000],
       [0.041, 0.000, 0.000, 0.000, 0.000, 0.000, 0.178, 0.000],
       [0.100, 0.738, 0.045, 0.002, 0.050, 0.008, 0.208, 0.034]])

    truePermanences = [
      [0.210, 0.130, 0.100, 0.000, 0.000, 0.000, 0.000, 0.000],
  #    Inc    Inc    Inc    Trim    -     -     -    -
      [0.160, 0.000, 0.000, 0.000, 0.190, 0.130, 0.000, 0.460],
  #    Inc   -     -    -     Inc   Inc    -     Inc
      [0.000, 0.000, 0.014, 0.000, 0.032, 0.044, 0.110, 0.000], #unchanged
  #    -    -     -    -     -    -     -    -
      [0.051, 0.000, 0.000, 0.000, 0.000, 0.000, 0.188, 0.000],
  #    Inc   Trim    Trim    -     -    -    Inc     -
      [0.110, 0.748, 0.055, 0.000, 0.060, 0.000, 0.218, 0.000]]

    sp._bumpUpWeakColumns()
    for i in xrange(sp._numColumns):
      perm = list(sp._permanences.getRow(i))
      for j in xrange(sp._numInputs):
        self.assertAlmostEqual(truePermanences[i][j], perm[j])
开发者ID:Ueelee,项目名称:nupic,代码行数:41,代码来源:spatial_pooler_test.py

示例2: testAdaptSynapses

# 需要导入模块: from nupic.research.spatial_pooler import SpatialPooler [as 别名]
# 或者: from nupic.research.spatial_pooler.SpatialPooler import _potentialPools [as 别名]
  def testAdaptSynapses(self):
    sp = SpatialPooler(inputDimensions=[8],
                       columnDimensions=[4],
                       synPermInactiveDec=0.01,
                       synPermActiveInc=0.1,
                       synPermActiveSharedDec=0.02,
                       synPermOrphanDec=0.03)
    sp._synPermTrimThreshold = 0.05

    sp._potentialPools = SparseBinaryMatrix(
        [[1, 1, 1, 1, 0, 0, 0, 0],
         [1, 0, 0, 0, 1, 1, 0, 1],
         [0, 0, 1, 0, 0, 0, 1, 0],
         [1, 0, 0, 0, 0, 0, 1, 0]])

    inputVector = numpy.array([1, 0, 0, 1, 1, 0, 1, 0])
    sharedInputs = numpy.where(numpy.array(
        [1, 0, 0, 0, 0, 0, 1, 0]) > 0)[0]
    activeColumns = numpy.array([0,1,2])

    sp._permanences = SparseMatrix(
        [[0.200, 0.120, 0.090, 0.040, 0.000, 0.000, 0.000, 0.000],
         [0.150, 0.000, 0.000, 0.000, 0.180, 0.120, 0.000, 0.450],
         [0.000, 0.000, 0.014, 0.000, 0.000, 0.000, 0.110, 0.000],
         [0.040, 0.000, 0.000, 0.000, 0.000, 0.000, 0.178, 0.000]])

    truePermanences = [
        [0.280, 0.110, 0.080, 0.140, 0.000, 0.000, 0.000, 0.000],
      #  Inc/Sh   Dec     Dec    Inc   -    -    -  -
        [0.230, 0.000, 0.000, 0.000, 0.280, 0.110, 0.000, 0.440],
      #  Inc/Sh    -      -     -      Inc    Dec    -     Dec  
        [0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.190, 0.000],
      #   -      -     Trim     -     -     -    Inc/Sh   - 
        [0.040, 0.000, 0.000, 0.000, 0.000, 0.000, 0.178, 0.000]]
      #   -      -      -    -      -    -    -    -   -   

    sp._adaptSynapses(inputVector,sharedInputs, activeColumns)
    for i in xrange(sp._numColumns):
      perm = list(sp._permanences.getRow(i))
      for j in xrange(sp._numInputs):
        self.assertAlmostEqual(truePermanences[i][j], perm[j])

    # test orphan columns
    sp._potentialPools = SparseBinaryMatrix(
        [[1, 1, 1, 0, 0, 0, 0, 0],
         [0, 1, 1, 1, 0, 0, 0, 0],
         [0, 0, 1, 1, 1, 0, 0, 0],
         [1, 0, 0, 0, 0, 0, 1, 0]])

    inputVector = numpy.array([1, 0, 0, 1, 1, 0, 1, 0])
    sharedInputs = numpy.where(numpy.array([1, 0, 0, 1, 0, 0, 0, 0]) > 0)[0]
    activeColumns = numpy.array([0,1,2])

    sp._permanences = SparseMatrix(
        [[0.200, 0.120, 0.090, 0.000, 0.000, 0.000, 0.000, 0.000],
         [0.000, 0.017, 0.232, 0.400, 0.000, 0.000, 0.000, 0.000],
         [0.000, 0.000, 0.014, 0.051, 0.730, 0.000, 0.000, 0.000],
         [0.170, 0.000, 0.000, 0.000, 0.000, 0.000, 0.380, 0.000]])

    truePermanences = [
        [0.280, 0.110, 0.080, 0.000, 0.000, 0.000, 0.000, 0.000],
        #  Inc/Sh    Dec     Dec     -       -    -    -    -
        [0.000, 0.000, 0.222, 0.480, 0.000, 0.000, 0.000, 0.000],
        #     -      Trim     Dec  Inc/Sh   -       -      -      -
        [0.000, 0.000, 0.000, 0.131, 0.830, 0.000, 0.000, 0.000],
        #   -      -      Trim Inc/Sh  Inc     -     -     -
        [0.170, 0.000, 0.000, 0.000, 0.000, 0.000, 0.380, 0.000]]
        #  -    -      -      -      -       -       -     -

    sp._adaptSynapses(inputVector,sharedInputs, activeColumns)
    for i in xrange(sp._numColumns):
      perm = list(sp._permanences.getRow(i))
      for j in xrange(sp._numInputs):
        self.assertAlmostEqual(truePermanences[i][j], perm[j])
开发者ID:Ueelee,项目名称:nupic,代码行数:76,代码来源:spatial_pooler_test.py


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