本文整理汇总了Python中nupic.encoders.scalar.ScalarEncoder.getDescription方法的典型用法代码示例。如果您正苦于以下问题:Python ScalarEncoder.getDescription方法的具体用法?Python ScalarEncoder.getDescription怎么用?Python ScalarEncoder.getDescription使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nupic.encoders.scalar.ScalarEncoder
的用法示例。
在下文中一共展示了ScalarEncoder.getDescription方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testBottomUpEncodingPeriodicEncoder
# 需要导入模块: from nupic.encoders.scalar import ScalarEncoder [as 别名]
# 或者: from nupic.encoders.scalar.ScalarEncoder import getDescription [as 别名]
def testBottomUpEncodingPeriodicEncoder(self):
"""Test bottom-up encoding for a Periodic encoder"""
l = ScalarEncoder(n=14, w=3, minval=1, maxval=8, periodic=True, forced=True)
self.assertEqual(l.getDescription(), [("[1:8]", 0)])
l = ScalarEncoder(name='scalar', n=14, w=3, minval=1, maxval=8, periodic=True, forced=True)
self.assertEqual(l.getDescription(), [("scalar", 0)])
self.assertTrue((l.encode(3) == numpy.array([0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0],
dtype=defaultDtype)).all())
self.assertTrue((l.encode(3.1) == l.encode(3)).all())
self.assertTrue((l.encode(3.5) == numpy.array([0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0],
dtype=defaultDtype)).all())
self.assertTrue((l.encode(3.6) == l.encode(3.5)).all())
self.assertTrue((l.encode(3.7) == l.encode(3.5)).all())
self.assertTrue((l.encode(4) == numpy.array([0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0],
dtype=defaultDtype)).all())
self.assertTrue((l.encode(1) == numpy.array([1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
dtype=defaultDtype)).all())
self.assertTrue((l.encode(1.5) == numpy.array([1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
dtype=defaultDtype)).all())
self.assertTrue((l.encode(7) == numpy.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1],
dtype=defaultDtype)).all())
self.assertTrue((l.encode(7.5) == numpy.array([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1],
dtype=defaultDtype)).all())
self.assertEqual(l.resolution, 0.5)
self.assertEqual(l.radius, 1.5)
示例2: testBottomUpEncodingPeriodicEncoder
# 需要导入模块: from nupic.encoders.scalar import ScalarEncoder [as 别名]
# 或者: from nupic.encoders.scalar.ScalarEncoder import getDescription [as 别名]
def testBottomUpEncodingPeriodicEncoder(self):
"""Test bottom-up encoding for a Periodic encoder"""
l = ScalarEncoder(n=14, w=3, minval=1, maxval=8, periodic=True)
assert l.getDescription() == [("[1:8]", 0)]
l = ScalarEncoder(name='scalar', n=14, w=3, minval=1, maxval=8, periodic=True)
assert l.getDescription() == [("scalar", 0)]
assert (l.encode(3) == numpy.array([0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0],
dtype=defaultDtype)).all()
assert (l.encode(3.1) == l.encode(3)).all()
assert (l.encode(3.5) == numpy.array([0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0],
dtype=defaultDtype)).all()
assert (l.encode(3.6) == l.encode(3.5)).all()
assert (l.encode(3.7) == l.encode(3.5)).all()
assert (l.encode(4) == numpy.array([0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0],
dtype=defaultDtype)).all()
assert (l.encode(1) == numpy.array([1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
dtype=defaultDtype)).all()
assert (l.encode(1.5) == numpy.array([1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
dtype=defaultDtype)).all()
assert (l.encode(7) == numpy.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1],
dtype=defaultDtype)).all()
assert (l.encode(7.5) == numpy.array([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1],
dtype=defaultDtype)).all()
assert l.resolution == 0.5
assert l.radius == 1.5