本文整理汇总了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)