本文整理汇总了Python中nupic.bindings.algorithms.SpatialPooler.setSynPermTrimThreshold方法的典型用法代码示例。如果您正苦于以下问题:Python SpatialPooler.setSynPermTrimThreshold方法的具体用法?Python SpatialPooler.setSynPermTrimThreshold怎么用?Python SpatialPooler.setSynPermTrimThreshold使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nupic.bindings.algorithms.SpatialPooler
的用法示例。
在下文中一共展示了SpatialPooler.setSynPermTrimThreshold方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testUpdatePermanencesForColumn
# 需要导入模块: from nupic.bindings.algorithms import SpatialPooler [as 别名]
# 或者: from nupic.bindings.algorithms.SpatialPooler import setSynPermTrimThreshold [as 别名]
def testUpdatePermanencesForColumn(self):
sp = SpatialPooler(inputDimensions = [5],
columnDimensions = [5])
sp.setSynPermTrimThreshold(0.05)
permanencesList = [
[ -0.10, 0.500, 0.400, 0.010, 0.020 ],
[ 0.300, 0.010, 0.020, 0.120, 0.090 ],
[ 0.070, 0.050, 1.030, 0.190, 0.060 ],
[ 0.180, 0.090, 0.110, 0.010, 0.030 ],
[ 0.200, 0.101, 0.050, -0.09, 1.100 ]]
expectedPermanencesList = [
[ 0.000, 0.500, 0.400, 0.000, 0.000],
# Clip - - Trim Trim
[0.300, 0.000, 0.000, 0.120, 0.090],
# - Trim Trim - -
[0.070, 0.050, 1.000, 0.190, 0.060],
# - - Clip - -
[0.180, 0.090, 0.110, 0.000, 0.000],
# - - - Trim Trim
[0.200, 0.101, 0.050, 0.000, 1.000]]
# - - - Clip Clip
expectedConnectedSynapsesList = [
[0, 1, 1, 0, 0],
[1, 0, 0, 1, 0],
[0, 0, 1, 1, 0],
[1, 0, 1, 0, 0],
[1, 1, 0, 0, 1]]
expectedConnectedCounts = [2, 2, 2, 2, 3]
for i in xrange(5):
permanences = np.array(permanencesList[i], dtype=realDType)
expectedPermanences = np.array(expectedPermanencesList[i],
dtype=realDType)
expectedConnectedSynapses = expectedConnectedSynapsesList[i]
sp._updatePermanencesForColumn(permanences, i, False)
updatedPermanences = np.zeros(5, dtype=realDType)
connectedSynapses = np.zeros(5, dtype=uintDType)
connectedCounts = np.zeros(5, dtype=uintDType)
sp.getPermanence(i, updatedPermanences)
sp.getConnectedSynapses(i, connectedSynapses)
sp.getConnectedCounts(connectedCounts)
np.testing.assert_almost_equal(updatedPermanences, expectedPermanences)
self.assertEqual(list(connectedSynapses), expectedConnectedSynapses)
self.assertEqual(connectedCounts[i], expectedConnectedCounts[i])
示例2: convertSP
# 需要导入模块: from nupic.bindings.algorithms import SpatialPooler [as 别名]
# 或者: from nupic.bindings.algorithms.SpatialPooler import setSynPermTrimThreshold [as 别名]
def convertSP(self, pySp, newSeed):
columnDim = pySp._columnDimensions
inputDim = pySp._inputDimensions
numInputs = pySp.getNumInputs()
numColumns = pySp.getNumColumns()
cppSp = CPPSpatialPooler(inputDim,columnDim)
cppSp.setPotentialRadius(pySp.getPotentialRadius())
cppSp.setPotentialPct(pySp.getPotentialPct())
cppSp.setGlobalInhibition(pySp.getGlobalInhibition())
numActiveColumnsPerInhArea = pySp.getNumActiveColumnsPerInhArea()
localAreaDensity = pySp.getLocalAreaDensity()
if (numActiveColumnsPerInhArea > 0):
cppSp.setNumActiveColumnsPerInhArea(numActiveColumnsPerInhArea)
else:
cppSp.setLocalAreaDensity(localAreaDensity)
cppSp.setStimulusThreshold(pySp.getStimulusThreshold())
cppSp.setInhibitionRadius(pySp.getInhibitionRadius())
cppSp.setDutyCyclePeriod(pySp.getDutyCyclePeriod())
cppSp.setMaxBoost(pySp.getMaxBoost())
cppSp.setIterationNum(pySp.getIterationNum())
cppSp.setIterationLearnNum(pySp.getIterationLearnNum())
cppSp.setSpVerbosity(pySp.getSpVerbosity())
cppSp.setUpdatePeriod(pySp.getUpdatePeriod())
cppSp.setSynPermTrimThreshold(pySp.getSynPermTrimThreshold())
cppSp.setSynPermActiveInc(pySp.getSynPermActiveInc())
cppSp.setSynPermInactiveDec(pySp.getSynPermInactiveDec())
cppSp.setSynPermBelowStimulusInc(pySp.getSynPermBelowStimulusInc())
cppSp.setSynPermConnected(pySp.getSynPermConnected())
cppSp.setMinPctOverlapDutyCycles(pySp.getMinPctOverlapDutyCycles())
cppSp.setMinPctActiveDutyCycles(pySp.getMinPctActiveDutyCycles())
boostFactors = numpy.zeros(numColumns).astype(realType)
pySp.getBoostFactors(boostFactors)
cppSp.setBoostFactors(boostFactors)
overlapDuty = numpy.zeros(numColumns).astype(realType)
pySp.getOverlapDutyCycles(overlapDuty)
cppSp.setOverlapDutyCycles(overlapDuty)
activeDuty = numpy.zeros(numColumns).astype(realType)
pySp.getActiveDutyCycles(activeDuty)
cppSp.setActiveDutyCycles(activeDuty)
minOverlapDuty = numpy.zeros(numColumns).astype(realType)
pySp.getMinOverlapDutyCycles(minOverlapDuty)
cppSp.setMinOverlapDutyCycles(minOverlapDuty)
minActiveDuty = numpy.zeros(numColumns).astype(realType)
pySp.getMinActiveDutyCycles(minActiveDuty)
cppSp.setMinActiveDutyCycles(minActiveDuty)
for i in xrange(numColumns):
potential = numpy.zeros(numInputs).astype(uintType)
pySp.getPotential(i, potential)
cppSp.setPotential(i, potential)
perm = numpy.zeros(numInputs).astype(realType)
pySp.getPermanence(i, perm)
cppSp.setPermanence(i, perm)
pySp._random = NupicRandom(newSeed)
cppSp.seed_(newSeed)
return cppSp
示例3: SpatialPoolerAPITest
# 需要导入模块: from nupic.bindings.algorithms import SpatialPooler [as 别名]
# 或者: from nupic.bindings.algorithms.SpatialPooler import setSynPermTrimThreshold [as 别名]
#.........这里部分代码省略.........
self.assertEqual(inParam, outParam)
def testGetBoostStrength(self):
inParam = 78
self.sp.setBoostStrength(inParam)
outParam = self.sp.getBoostStrength()
self.assertEqual(inParam, outParam)
def testGetIterationNum(self):
inParam = 999
self.sp.setIterationNum(inParam)
outParam = self.sp.getIterationNum()
self.assertEqual(inParam, outParam)
def testGetIterationLearnNum(self):
inParam = 666
self.sp.setIterationLearnNum(inParam)
outParam = self.sp.getIterationLearnNum()
self.assertEqual(inParam, outParam)
def testGetSpVerbosity(self):
inParam = 2
self.sp.setSpVerbosity(inParam)
outParam = self.sp.getSpVerbosity()
self.assertEqual(inParam, outParam)
def testGetSynPermTrimThreshold(self):
inParam = 0.7
self.sp.setSynPermTrimThreshold(inParam)
outParam = self.sp.getSynPermTrimThreshold()
self.assertAlmostEqual(inParam, outParam)
def testGetSynPermActiveInc(self):
inParam = 0.567
self.sp.setSynPermActiveInc(inParam)
outParam = self.sp.getSynPermActiveInc()
self.assertAlmostEqual(inParam, outParam)
def testGetSynPermInactiveDec(self):
inParam = 0.123
self.sp.setSynPermInactiveDec(inParam)
outParam = self.sp.getSynPermInactiveDec()
self.assertAlmostEqual(inParam, outParam)
def testGetSynPermBelowStimulusInc(self):
inParam = 0.0898
self.sp.setSynPermBelowStimulusInc(inParam)
outParam = self.sp.getSynPermBelowStimulusInc()
self.assertAlmostEqual(inParam, outParam)
def testGetSynPermConnected(self):
inParam = 0.514
self.sp.setSynPermConnected(inParam)
outParam = self.sp.getSynPermConnected()
self.assertAlmostEqual(inParam, outParam)