本文整理汇总了Python中nupic.bindings.algorithms.SpatialPooler._calculateOverlap方法的典型用法代码示例。如果您正苦于以下问题:Python SpatialPooler._calculateOverlap方法的具体用法?Python SpatialPooler._calculateOverlap怎么用?Python SpatialPooler._calculateOverlap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nupic.bindings.algorithms.SpatialPooler
的用法示例。
在下文中一共展示了SpatialPooler._calculateOverlap方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testCalculateOverlap
# 需要导入模块: from nupic.bindings.algorithms import SpatialPooler [as 别名]
# 或者: from nupic.bindings.algorithms.SpatialPooler import _calculateOverlap [as 别名]
def testCalculateOverlap(self):
sp = SpatialPooler(inputDimensions = [10],
columnDimensions = [5])
permanences = [
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[0, 0, 1, 1, 1, 1, 1, 1, 1, 1],
[0, 0, 0, 0, 1, 1, 1, 1, 1, 1],
[0, 0, 0, 0, 0, 0, 1, 1, 1, 1],
[0, 0, 0, 0, 0, 0, 0, 0, 1, 1]
]
inputVectors = [
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[0, 1, 0, 1, 0, 1, 0, 1, 0, 1],
[1, 1, 1, 1, 1, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 1]
]
expectedOverlaps = [
[0, 0, 0, 0, 0],
[10, 8, 6, 4, 2],
[5, 4, 3, 2, 1],
[5, 3, 1, 0, 0],
[1, 1, 1, 1, 1]
]
for column, permanence in enumerate(permanences):
sp.setPermanence(column, np.array(permanence, dtype=realDType))
for inputVector, expectedOverlap in zip(inputVectors, expectedOverlaps):
inputVector = np.array(inputVector, dtype=uintDType)
overlap = set(sp._calculateOverlap(inputVector))
expected = set(expectedOverlap)
self.assertSetEqual(overlap, expected,
"Input: {0}\tExpected: {1}\tActual: {2}".format(
inputVector, expected, overlap))