本文整理汇总了Python中nupic.research.spatial_pooler.SpatialPooler.getPermanence方法的典型用法代码示例。如果您正苦于以下问题:Python SpatialPooler.getPermanence方法的具体用法?Python SpatialPooler.getPermanence怎么用?Python SpatialPooler.getPermanence使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nupic.research.spatial_pooler.SpatialPooler
的用法示例。
在下文中一共展示了SpatialPooler.getPermanence方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Region
# 需要导入模块: from nupic.research.spatial_pooler import SpatialPooler [as 别名]
# 或者: from nupic.research.spatial_pooler.SpatialPooler import getPermanence [as 别名]
#.........这里部分代码省略.........
for inputElem in self._inputMap:
if inputElem.isActive.atCurrStep():
inputList.append(1)
else:
inputList.append(0)
input = numpy.array(inputList)
return input
def updateSpatialElements(self, activeColumns):
"""
Update elements regarding spatial pooler
"""
# Update proximal segments and synapses according to active columns
for colIdx in range(len(self.columns)):
column = self.columns[colIdx]
# Update proximal segment
segment = column.segment
if activeColumns[colIdx] == 1:
segment.isActive.setForCurrStep(True)
else:
segment.isActive.setForCurrStep(False)
# Check if proximal segment is predicted by check if the column has any predicted cell
for cell in column.cells:
if cell.index in self.temporalPooler.predictiveCells:
segment.isPredicted.setForCurrStep(True)
# Update proximal synapses
if segment.isActive.atCurrStep() or segment.isPredicted.atCurrStep():
permanencesSynapses = []
self.spatialPooler.getPermanence(colIdx, permanencesSynapses)
connectedSynapses = []
self.spatialPooler.getConnectedSynapses(colIdx, connectedSynapses)
for synIdx in range(len(permanencesSynapses)):
# Get the proximal synapse given its position in the input map
# Create a new one if it doesn't exist
synapse = segment.getSynapse(synIdx)
# Update proximal synapse
if permanencesSynapses[synIdx] > 0.:
if synapse == None:
# Create a new synapse to a input element
# An input element is a column if feeder is a region
# or then a bit if feeder is a sensor
synapse = Synapse()
synapse.inputElem = self._inputMap[synIdx]
synapse.indexSP = synIdx
segment.synapses.append(synapse)
# Update state
synapse.isRemoved.setForCurrStep(False)
synapse.permanence.setForCurrStep(permanencesSynapses[synIdx])
if connectedSynapses[synIdx] == 1:
synapse.isConnected.setForCurrStep(True)
else:
synapse.isConnected.setForCurrStep(False)
else:
if synapse != None:
synapse.isRemoved.setForCurrStep(True)
def updateTemporalElements(self):
"""
Update elements regarding temporal pooler
示例2: SpatialPoolerAPITest
# 需要导入模块: from nupic.research.spatial_pooler import SpatialPooler [as 别名]
# 或者: from nupic.research.spatial_pooler.SpatialPooler import getPermanence [as 别名]
#.........这里部分代码省略.........
def testGetSynPermConnected(self):
inParam = 0.514
self.sp.setSynPermConnected(inParam)
outParam = self.sp.getSynPermConnected()
self.assertAlmostEqual(inParam, outParam)
def testGetMinPctOverlapDutyCycles(self):
inParam = 0.11122
self.sp.setMinPctOverlapDutyCycles(inParam)
outParam = self.sp.getMinPctOverlapDutyCycles()
self.assertAlmostEqual(inParam, outParam)
def testGetMinPctActiveDutyCycles(self):
inParam = 0.444333
self.sp.setMinPctActiveDutyCycles(inParam)
outParam = self.sp.getMinPctActiveDutyCycles()
self.assertAlmostEqual(inParam, outParam)
def testGetPermanence(self):
numInputs = 5
numColumns = 5
self.sp.initialize(columnDimensions=[numInputs],
inputDimensions=[numColumns],
potentialRadius=1,
potentialPct=1)
inParam = numpy.array(
[0.06, 0.07, 0.08, 0.12, 0.13]).astype(realType)
self.sp.setPermanence(0,inParam)
outParam = numpy.zeros(numInputs).astype(realType)
self.sp.getPermanence(0, outParam)
self.assertListEqual(list(inParam),list(outParam))
def testGetBoostFactors(self):
numInputs = 3
numColumns = 3
self.sp.initialize(columnDimensions=[numInputs],
inputDimensions=[numColumns])
inParam = numpy.array([1, 1.2, 1.3, ]).astype(realType)
self.sp.setBoostFactors(inParam)
outParam = numpy.zeros(numInputs).astype(realType)
self.sp.getBoostFactors(outParam)
self.assertListEqual(list(inParam),list(outParam))
def testGetOverlapDutyCycles(self):
numInputs = 3
numColumns = 3
self.sp.initialize(columnDimensions=[numInputs],
inputDimensions=[numColumns])
inParam = numpy.array([0.9, 0.3, 0.1]).astype(realType)
self.sp.setOverlapDutyCycles(inParam)
outParam = numpy.zeros(numInputs).astype(realType)
self.sp.getOverlapDutyCycles(outParam)
self.assertListEqual(list(inParam),list(outParam))
def testGetActiveDutyCycles(self):
numInputs = 3
numColumns = 3
self.sp.initialize(columnDimensions=[numInputs],
inputDimensions=[numColumns])