NuPIC
0.2.7.dev0
Numenta Platform for Intelligent Computing

This class implements the spatial pooler. More...
Inherits object.
Public Member Functions  
def  __init__ 
Parameters:More...  
def  getColumnDimensions 
Returns the dimensions of the columns in the region.  
def  getInputDimensions 
Returns the dimensions of the input vector.  
def  getNumColumns 
Returns the total number of columns.  
def  getNumInputs 
Returns the total number of inputs.  
def  getPotentialRadius 
Returns the potential radius.  
def  setPotentialRadius 
Sets the potential radius.  
def  getPotentialPct 
Returns the potential percent.  
def  setPotentialPct 
Sets the potential percent.  
def  getGlobalInhibition 
Returns whether global inhibition is enabled.  
def  setGlobalInhibition 
Sets global inhibition.  
def  getNumActiveColumnsPerInhArea 
Returns the number of active columns per inhibition area. More...  
def  setNumActiveColumnsPerInhArea 
Sets the number of active columns per inhibition area. More...  
def  getLocalAreaDensity 
Returns the local area density. More...  
def  setLocalAreaDensity 
Sets the local area density. More...  
def  getStimulusThreshold 
Returns the stimulus threshold.  
def  setStimulusThreshold 
Sets the stimulus threshold.  
def  getInhibitionRadius 
Returns the inhibition radius.  
def  setInhibitionRadius 
Sets the inhibition radius.  
def  getDutyCyclePeriod 
Returns the duty cycle period.  
def  setDutyCyclePeriod 
Sets the duty cycle period.  
def  getMaxBoost 
Returns the maximum boost value.  
def  setMaxBoost 
Sets the maximum boost value.  
def  getIterationNum 
Returns the iteration number.  
def  setIterationNum 
Sets the iteration number.  
def  getIterationLearnNum 
Returns the learning iteration number.  
def  setIterationLearnNum 
Sets the learning iteration number.  
def  getSpVerbosity 
Returns the verbosity level.  
def  setSpVerbosity 
Sets the verbosity level.  
def  getUpdatePeriod 
Returns the update period.  
def  setUpdatePeriod 
Sets the update period.  
def  getSynPermTrimThreshold 
Returns the permanence trim threshold.  
def  setSynPermTrimThreshold 
Sets the permanence trim threshold.  
def  getSynPermActiveInc 
Returns the permanence increment amount for active synapses inputs.  
def  setSynPermActiveInc 
Sets the permanence increment amount for active synapses.  
def  getSynPermInactiveDec 
Returns the permanence decrement amount for inactive synapses.  
def  setSynPermInactiveDec 
Sets the permanence decrement amount for inactive synapses.  
def  getSynPermBelowStimulusInc 
Returns the permanence increment amount for columns that have not been recently active.  
def  setSynPermBelowStimulusInc 
Sets the permanence increment amount for columns that have not been recently active.  
def  getSynPermConnected 
Returns the permanence amount that qualifies a synapse as being connected.  
def  setSynPermConnected 
Sets the permanence amount that qualifies a synapse as being connected.  
def  getMinPctOverlapDutyCycles 
Returns the minimum tolerated overlaps, given as percent of neighbors overlap score.  
def  setMinPctOverlapDutyCycles 
Sets the minimum tolerated activity duty cycle, given as percent of neighbors' activity duty cycle.  
def  getMinPctActiveDutyCycles 
Returns the minimum tolerated activity duty cycle, given as percent of neighbors' activity duty cycle.  
def  setMinPctActiveDutyCycles 
Sets the minimum tolerated activity duty, given as percent of neighbors' activity duty cycle.  
def  getBoostFactors 
Returns the boost factors for all columns. More...  
def  setBoostFactors 
Sets the boost factors for all columns. More...  
def  getOverlapDutyCycles 
Returns the overlap duty cycles for all columns. More...  
def  setOverlapDutyCycles 
Sets the overlap duty cycles for all columns. More...  
def  getActiveDutyCycles 
Returns the activity duty cycles for all columns. More...  
def  setActiveDutyCycles 
Sets the activity duty cycles for all columns. More...  
def  getMinOverlapDutyCycles 
Returns the minimum overlap duty cycles for all columns. More...  
def  setMinOverlapDutyCycles 
Sets the minimum overlap duty cycles for all columns. More...  
def  getMinActiveDutyCycles 
Returns the minimum activity duty cycles for all columns. More...  
def  setMinActiveDutyCycles 
Sets the minimum activity duty cycles for all columns. More...  
def  getPotential 
Returns the potential mapping for a given column. More...  
def  setPotential 
Sets the potential mapping for a given column. More...  
def  getPermanence 
Returns the permanence values for a given column. More...  
def  setPermanence 
Sets the permanence values for a given column. More...  
def  getConnectedSynapses 
Returns the connected synapses for a given column. More...  
def  getConnectedCounts 
Returns the number of connected synapses for all columns. More...  
def  compute 
This is the primary public method of the SpatialPooler class. More...  
def  stripUnlearnedColumns 
Removes the set of columns who have never been active from the set of active columns selected in the inhibition round. More...  
def  __setstate__ 
Initialize class properties from stored values.  
def  printParameters 
Useful for debugging.  
This class implements the spatial pooler.
It is in charge of handling the relationships between the columns of a region and the inputs bits. The primary public interface to this function is the "compute" method, which takes in an input vector and returns a list of activeColumns columns. Example Usage:
sp = SpatialPooler(...) for line in file: inputVector = numpy.array(line) sp.compute(inputVector) ...
def __init__  (  self,  
inputDimensions = (32,32 , 

columnDimensions = (64,64 , 

potentialRadius = 16 , 

potentialPct = 0.5 , 

globalInhibition = False , 

localAreaDensity = 1.0 , 

numActiveColumnsPerInhArea = 10.0 , 

stimulusThreshold = 0 , 

synPermInactiveDec = 0.008 , 

synPermActiveInc = 0.05 , 

synPermConnected = 0.10 , 

minPctOverlapDutyCycle = 0.001 , 

minPctActiveDutyCycle = 0.001 , 

dutyCyclePeriod = 1000 , 

maxBoost = 10.0 , 

seed = 1 , 

spVerbosity = 0 , 

wrapAround = True 

) 
inputDimensions,:  A list representing the dimensions of the input vector. Format is [height, width, depth, ...], where each value represents the size of the dimension. For a topology of one dimension with 100 inputs use 100, or [100]. For a two dimensional topology of 10x5 use [10,5]. 
columnDimensions,:  A list representing the dimensions of the columns in the region. Format is [height, width, depth, ...], where each value represents the size of the dimension. For a topology of one dimension with 2000 columns use 2000, or [2000]. For a three dimensional topology of 32x64x16 use [32, 64, 16]. 
potentialRadius,:  This parameter determines the extent of the input that each column can potentially be connected to. This can be thought of as the input bits that are visible to each column, or a 'receptiveField' of the field of vision. A large enough value will result in 'global coverage', meaning that each column can potentially be connected to every input bit. This parameter defines a square (or hyper square) area: a column will have a max square potential pool with sides of length 2 * potentialRadius + 1. 
potentialPct,:  The percent of the inputs, within a column's potential radius, that a column can be connected to. If set to 1, the column will be connected to every input within its potential radius. This parameter is used to give each column a unique potential pool when a large potentialRadius causes overlap between the columns. At initialization time we choose ((2*potentialRadius + 1)^(# inputDimensions) * potentialPct) input bits to comprise the column's potential pool. 
globalInhibition,:  If true, then during inhibition phase the winning columns are selected as the most active columns from the region as a whole. Otherwise, the winning columns are selected with respect to their local neighborhoods. Using global inhibition boosts performance x60. 
localAreaDensity,:  The desired density of active columns within a local inhibition area (the size of which is set by the internally calculated inhibitionRadius, which is in turn determined from the average size of the connected potential pools of all columns). The inhibition logic will insure that at most N columns remain ON within a local inhibition area, where N = localAreaDensity * (total number of columns in inhibition area). 
numActiveColumnsPerInhArea,:  An alternate way to control the density of the active columns. If numActiveColumnsPerInhArea is specified then localAreaDensity must be less than 0, and vice versa. When using numActiveColumnsPerInhArea, the inhibition logic will insure that at most 'numActiveColumnsPerInhArea' columns remain ON within a local inhibition area (the size of which is set by the internally calculated inhibitionRadius, which is in turn determined from the average size of the connected receptive fields of all columns). When using this method, as columns learn and grow their effective receptive fields, the inhibitionRadius will grow, and hence the net density of the active columns will decrease. This is in contrast to the localAreaDensity method, which keeps the density of active columns the same regardless of the size of their receptive fields. 
stimulusThreshold,:  This is a number specifying the minimum number of synapses that must be on in order for a columns to turn ON. The purpose of this is to prevent noise input from activating columns. Specified as a percent of a fully grown synapse. 
synPermInactiveDec,:  The amount by which an inactive synapse is decremented in each round. Specified as a percent of a fully grown synapse. 
synPermActiveInc,:  The amount by which an active synapse is incremented in each round. Specified as a percent of a fully grown synapse. 
synPermConnected,:  The default connected threshold. Any synapse whose permanence value is above the connected threshold is a "connected synapse", meaning it can contribute to the cell's firing. 
minPctOverlapDutyCycle,:  A number between 0 and 1.0, used to set a floor on how often a column should have at least stimulusThreshold active inputs. Periodically, each column looks at the overlap duty cycle of all other columns within its inhibition radius and sets its own internal minimal acceptable duty cycle to: minPctDutyCycleBeforeInh * max(other columns' duty cycles). On each iteration, any column whose overlap duty cycle falls below this computed value will get all of its permanence values boosted up by synPermActiveInc. Raising all permanences in response to a subpar duty cycle before inhibition allows a cell to search for new inputs when either its previously learned inputs are no longer ever active, or when the vast majority of them have been "hijacked" by other columns. 
minPctActiveDutyCycle,:  A number between 0 and 1.0, used to set a floor on how often a column should be activate. Periodically, each column looks at the activity duty cycle of all other columns within its inhibition radius and sets its own internal minimal acceptable duty cycle to: minPctDutyCycleAfterInh * max(other columns' duty cycles). On each iteration, any column whose duty cycle after inhibition falls below this computed value will get its internal boost factor increased. 
dutyCyclePeriod,:  The period used to calculate duty cycles. Higher values make it take longer to respond to changes in boost or synPerConnectedCell. Shorter values make it more unstable and likely to oscillate. 
maxBoost,:  The maximum overlap boost factor. Each column's overlap gets multiplied by a boost factor before it gets considered for inhibition. The actual boost factor for a column is number between 1.0 and maxBoost. A boost factor of 1.0 is used if the duty cycle is >= minOverlapDutyCycle, maxBoost is used if the duty cycle is 0, and any duty cycle in between is linearly extrapolated from these 2 endpoints. 
seed,:  Seed for our own pseudorandom number generator. 
spVerbosity,:  spVerbosity level: 0, 1, 2, or 3 
wrapAround,:  Determines if inputs at the beginning and end of an input dimension should be considered neighbors when mapping columns to inputs. 
def compute  (  self,  
inputVector,  
learn,  
activeArray  
) 
This is the primary public method of the SpatialPooler class.
This function takes a input vector and outputs the indices of the active columns. If 'learn' is set to True, this method also updates the permanences of the columns.
inputVector,:  A numpy array of 0's and 1's that comprises the input to the spatial pooler. The array will be treated as a one dimensional array, therefore the dimensions of the array do not have to match the exact dimensions specified in the class constructor. In fact, even a list would suffice. The number of input bits in the vector must, however, match the number of bits specified by the call to the constructor. Therefore there must be a '0' or '1' in the array for every input bit. 
learn,:  A boolean value indicating whether learning should be performed. Learning entails updating the permanence values of the synapses, and hence modifying the 'state' of the model. Setting learning to 'off' freezes the SP and has many uses. For example, you might want to feed in various inputs and examine the resulting SDR's. 
activeArray,:  An array whose size is equal to the number of columns. Before the function returns this array will be populated with 1's at the indices of the active columns, and 0's everywhere else. 
def getActiveDutyCycles  (  self,  
activeDutyCycles  
) 
Returns the activity duty cycles for all columns.
'activeDutyCycles' size must match the number of columns
def getBoostFactors  (  self,  
boostFactors  
) 
Returns the boost factors for all columns.
'boostFactors' size must match the number of columns
def getConnectedCounts  (  self,  
connectedCounts  
) 
Returns the number of connected synapses for all columns.
'connectedCounts' size must match the number of columns
def getConnectedSynapses  (  self,  
column,  
connectedSynapses  
) 
Returns the connected synapses for a given column.
'connectedSynapses' size must match the number of inputs
def getLocalAreaDensity  (  self  ) 
Returns the local area density.
Returns a value less than 0 if parameter is unused
def getMinActiveDutyCycles  (  self,  
minActiveDutyCycles  
) 
Returns the minimum activity duty cycles for all columns.
'_minActiveDutyCycles' size must match the number of columns
def getMinOverlapDutyCycles  (  self,  
minOverlapDutyCycles  
) 
Returns the minimum overlap duty cycles for all columns.
'_minOverlapDutyCycles' size must match the number of columns
def getNumActiveColumnsPerInhArea  (  self  ) 
Returns the number of active columns per inhibition area.
Returns a value less than 0 if parameter is unused
def getOverlapDutyCycles  (  self,  
overlapDutyCycles  
) 
Returns the overlap duty cycles for all columns.
'overlapDutyCycles' size must match the number of columns
def getPermanence  (  self,  
column,  
permanence  
) 
Returns the permanence values for a given column.
'permanence' size must match the number of inputs
def getPotential  (  self,  
column,  
potential  
) 
Returns the potential mapping for a given column.
'potential' size must match the number of inputs
def setActiveDutyCycles  (  self,  
activeDutyCycles  
) 
Sets the activity duty cycles for all columns.
'activeDutyCycles' size must match the number of columns
def setBoostFactors  (  self,  
boostFactors  
) 
Sets the boost factors for all columns.
'boostFactors' size must match the number of columns
def setLocalAreaDensity  (  self,  
localAreaDensity  
) 
Sets the local area density.
Invalidates the 'numActiveColumnsPerInhArea' parameter
def setMinActiveDutyCycles  (  self,  
minActiveDutyCycles  
) 
Sets the minimum activity duty cycles for all columns.
'_minActiveDutyCycles' size must match the number of columns
def setMinOverlapDutyCycles  (  self,  
minOverlapDutyCycles  
) 
Sets the minimum overlap duty cycles for all columns.
'_minOverlapDutyCycles' size must match the number of columns
def setNumActiveColumnsPerInhArea  (  self,  
numActiveColumnsPerInhArea  
) 
Sets the number of active columns per inhibition area.
Invalidates the 'localAreaDensity' parameter
def setOverlapDutyCycles  (  self,  
overlapDutyCycles  
) 
Sets the overlap duty cycles for all columns.
'overlapDutyCycles' size must match the number of columns
def setPermanence  (  self,  
column,  
permanence  
) 
Sets the permanence values for a given column.
'permanence' size must match the number of inputs
def setPotential  (  self,  
column,  
potential  
) 
Sets the potential mapping for a given column.
'potential' size must match the number of inputs, and must be greater than _stimulusThreshold
def stripUnlearnedColumns  (  self,  
activeArray  
) 
Removes the set of columns who have never been active from the set of active columns selected in the inhibition round.
Such columns cannot represent learned pattern and are therefore meaningless if only inference is required. This should not be done when using a random, unlearned SP since you would end up with no active columns.
activeArray,:  An array whose size is equal to the number of columns. Any columns marked as active with an activeDutyCycle of 0 have never been activated before and therefore are not active due to learning. Any of these (unlearned) columns will be disabled (set to 0). 