本文整理汇总了Python中nupic.utils.MovingAverage.read方法的典型用法代码示例。如果您正苦于以下问题:Python MovingAverage.read方法的具体用法?Python MovingAverage.read怎么用?Python MovingAverage.read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nupic.utils.MovingAverage
的用法示例。
在下文中一共展示了MovingAverage.read方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testMovingAverageReadWrite
# 需要导入模块: from nupic.utils import MovingAverage [as 别名]
# 或者: from nupic.utils.MovingAverage import read [as 别名]
def testMovingAverageReadWrite(self):
ma = MovingAverage(windowSize=3)
ma.next(3)
ma.next(4)
ma.next(5)
proto1 = MovingAverageProto.new_message()
ma.write(proto1)
# Write the proto to a temp file and read it back into a new proto
with tempfile.TemporaryFile() as f:
proto1.write(f)
f.seek(0)
proto2 = MovingAverageProto.read(f)
resurrectedMa = MovingAverage.read(proto2)
newAverage = ma.next(6)
self.assertEqual(newAverage, resurrectedMa.next(6))
self.assertListEqual(ma.getSlidingWindow(),
resurrectedMa.getSlidingWindow())
self.assertEqual(ma.total, resurrectedMa.total)
示例2: read
# 需要导入模块: from nupic.utils import MovingAverage [as 别名]
# 或者: from nupic.utils.MovingAverage import read [as 别名]
def read(cls, proto):
encoder = super(AdaptiveScalarEncoder, cls).read(proto)
encoder.recordNum = proto.recordNum
encoder.slidingWindow = MovingAverage.read(proto.slidingWindow)
return encoder