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


Python SpatialPooler._updateDutyCyclesHelper方法代码示例

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


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

示例1: testUpdateDutyCycleHelper

# 需要导入模块: from nupic.research.spatial_pooler import SpatialPooler [as 别名]
# 或者: from nupic.research.spatial_pooler.SpatialPooler import _updateDutyCyclesHelper [as 别名]
  def testUpdateDutyCycleHelper(self):
    """
    Tests that duty cycles are updated properly according
    to the mathematical formula. also check the effects of
    supplying a maxPeriod to the function.
    """
    dc = numpy.zeros(5)
    dc = numpy.array([1000.0, 1000.0, 1000.0, 1000.0, 1000.0])
    period = 1000
    newvals = numpy.zeros(5)
    newDc = SpatialPooler._updateDutyCyclesHelper(dc, newvals, period)
    trueNewDc = [999, 999, 999, 999, 999]
    self.assertListEqual(list(newDc),trueNewDc)

    dc = numpy.array([1000.0, 1000.0, 1000.0, 1000.0, 1000.0])
    period = 1000
    newvals = numpy.zeros(5)
    newvals.fill(1000)
    newDc = SpatialPooler._updateDutyCyclesHelper(dc, newvals, period)
    trueNewDc = list(dc)
    self.assertListEqual(list(newDc), trueNewDc)

    dc = numpy.array([1000, 1000, 1000, 1000, 1000])
    newvals = numpy.array([2000, 4000, 5000, 6000, 7000])
    period = 1000
    newDc = SpatialPooler._updateDutyCyclesHelper(dc, newvals, period)
    trueNewDc = [1001, 1003, 1004, 1005, 1006]
    self.assertListEqual(list(newDc),trueNewDc)

    dc = numpy.array([1000, 800, 600, 400, 2000])
    newvals = numpy.zeros(5)
    period = 2
    newDc = SpatialPooler._updateDutyCyclesHelper(dc, newvals, period)
    trueNewDc = [500, 400, 300, 200, 1000]
    self.assertListEqual(list(newDc), trueNewDc)
开发者ID:Ueelee,项目名称:nupic,代码行数:37,代码来源:spatial_pooler_test.py


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