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


Python RandomDistributedScalarEncoder._countOverlap方法代码示例

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


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

示例1: testCountOverlap

# 需要导入模块: from nupic.encoders.random_distributed_scalar import RandomDistributedScalarEncoder [as 别名]
# 或者: from nupic.encoders.random_distributed_scalar.RandomDistributedScalarEncoder import _countOverlap [as 别名]
  def testCountOverlap(self):
    """
    Test that the internal method _countOverlap works as expected.
    """
    enc = RandomDistributedScalarEncoder(name='enc', resolution=1.0, n=500)

    r1 = numpy.array([1, 2, 3, 4, 5, 6])
    r2 = numpy.array([1, 2, 3, 4, 5, 6])
    self.assertEqual(enc._countOverlap(r1, r2), 6,
                     "_countOverlap result is incorrect")

    r1 = numpy.array([1, 2, 3, 4, 5, 6])
    r2 = numpy.array([1, 2, 3, 4, 5, 7])
    self.assertEqual(enc._countOverlap(r1, r2), 5,
                     "_countOverlap result is incorrect")

    r1 = numpy.array([1, 2, 3, 4, 5, 6])
    r2 = numpy.array([6, 5, 4, 3, 2, 1])
    self.assertEqual(enc._countOverlap(r1, r2), 6,
                     "_countOverlap result is incorrect")

    r1 = numpy.array([1, 2, 8, 4, 5, 6])
    r2 = numpy.array([1, 2, 3, 4, 9, 6])
    self.assertEqual(enc._countOverlap(r1, r2), 4,
                     "_countOverlap result is incorrect")

    r1 = numpy.array([1, 2, 3, 4, 5, 6])
    r2 = numpy.array([1, 2, 3])
    self.assertEqual(enc._countOverlap(r1, r2), 3,
                     "_countOverlap result is incorrect")

    r1 = numpy.array([7, 8, 9, 10, 11, 12])
    r2 = numpy.array([1, 2, 3, 4, 5, 6])
    self.assertEqual(enc._countOverlap(r1, r2), 0,
                     "_countOverlap result is incorrect")
开发者ID:AI-Cdrone,项目名称:nupic,代码行数:37,代码来源:random_distributed_scalar_test.py


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