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


Python SpatialPooler._calculateOverlap方法代码示例

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


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

示例1: testCalculateOverlap

# 需要导入模块: from nupic.bindings.algorithms import SpatialPooler [as 别名]
# 或者: from nupic.bindings.algorithms.SpatialPooler import _calculateOverlap [as 别名]
  def testCalculateOverlap(self):
    sp = SpatialPooler(inputDimensions = [10],
                       columnDimensions = [5])

    permanences = [
      [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
      [0, 0, 1, 1, 1, 1, 1, 1, 1, 1],
      [0, 0, 0, 0, 1, 1, 1, 1, 1, 1],
      [0, 0, 0, 0, 0, 0, 1, 1, 1, 1],
      [0, 0, 0, 0, 0, 0, 0, 0, 1, 1]
    ]
    inputVectors = [
      [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
      [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
      [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],
      [1, 1, 1, 1, 1, 0, 0, 0, 0, 0],
      [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]
    ]
    expectedOverlaps = [
      [0,  0,  0,  0,  0],
      [10, 8,  6,  4,  2],
      [5,  4,  3,  2,  1],
      [5,  3,  1,  0,  0],
      [1,  1,  1,  1,  1]
    ]

    for column, permanence in enumerate(permanences):
      sp.setPermanence(column, np.array(permanence, dtype=realDType))

    for inputVector, expectedOverlap in zip(inputVectors, expectedOverlaps):
      inputVector = np.array(inputVector, dtype=uintDType)
      overlap = set(sp._calculateOverlap(inputVector))
      expected = set(expectedOverlap)
      self.assertSetEqual(overlap, expected,
                          "Input: {0}\tExpected: {1}\tActual: {2}".format(
                            inputVector, expected, overlap))
开发者ID:Erichy94,项目名称:nupic,代码行数:38,代码来源:spatial_pooler_cpp_unit_test.py


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