NuPIC Core
Core algorithms for NuPIC(the Numenta Platform for Intelligent Computing), implemented in C++
 All Classes Namespaces Files Functions Typedefs Enumerations Enumerator Friends Pages
Public Member Functions | Static Public Member Functions | List of all members
nupic::algorithms::spatial_pooler::SpatialPooler Class Reference

CLA spatial pooler implementation in C++. More...

#include <SpatialPooler.hpp>

Public Member Functions

virtual void initialize (vector< UInt > inputDimensions, vector< UInt > columnDimensions, UInt potentialRadius=16, Real potentialPct=0.5, bool globalInhibition=true, Real localAreaDensity=-1.0, UInt numActiveColumnsPerInhArea=10, UInt stimulusThreshold=0, Real synPermInactiveDec=0.01, Real synPermActiveInc=0.1, Real synPermConnected=0.1, Real minPctOverlapDutyCycles=0.001, Real minPctActiveDutyCycles=0.001, UInt dutyCyclePeriod=1000, Real maxBoost=10.0, Int seed=1, UInt spVerbosity=0, bool wrapAround=true)
 Initialize the spatial pooler using the given parameters. More...
 
virtual void compute (UInt inputVector[], bool learn, UInt activeVector[])
 This is the main workshorse method of the SpatialPooler class. More...
 
void stripUnlearnedColumns (UInt activeArray[]) const
 Removes the set of columns who have never been active from the set of active columns selected in the inhibition round. More...
 
virtual UInt version () const
 Get the version number of this spatial pooler. More...
 
virtual void save (ostream &outStream) const
 Save (serialize) the current state of the spatial pooler to the specified file. More...
 
virtual void load (istream &inStream)
 Load (deserialize) and initialize the spatial pooler from the specified input stream. More...
 
virtual UInt persistentSize () const
 Returns the number of bytes that a save operation would result in. More...
 
vector< UIntgetColumnDimensions () const
 Returns the dimensions of the columns in the region. More...
 
vector< UIntgetInputDimensions () const
 Returns the dimensions of the input vector. More...
 
UInt getNumColumns () const
 Returns the total number of columns. More...
 
UInt getNumInputs () const
 Returns the total number of inputs. More...
 
UInt getPotentialRadius () const
 Returns the potential radius. More...
 
void setPotentialRadius (UInt potentialRadius)
 Sets the potential radius. More...
 
Real getPotentialPct () const
 Returns the potential percent. More...
 
void setPotentialPct (Real potentialPct)
 Sets the potential percent. More...
 
bool getGlobalInhibition () const
 
void setGlobalInhibition (bool globalInhibition)
 Sets global inhibition. More...
 
Int getNumActiveColumnsPerInhArea () const
 Returns the number of active columns per inhibition area. More...
 
void setNumActiveColumnsPerInhArea (UInt numActiveColumnsPerInhArea)
 Sets the number of active columns per inhibition area. More...
 
Real getLocalAreaDensity () const
 Returns the local area density. More...
 
void setLocalAreaDensity (Real localAreaDensity)
 Sets the local area density. More...
 
UInt getStimulusThreshold () const
 Returns the stimulus threshold. More...
 
void setStimulusThreshold (UInt stimulusThreshold)
 Sets the stimulus threshold. More...
 
UInt getInhibitionRadius () const
 Returns the inhibition radius. More...
 
void setInhibitionRadius (UInt inhibitionRadius)
 Sets the inhibition radius. More...
 
UInt getDutyCyclePeriod () const
 Returns the duty cycle period. More...
 
void setDutyCyclePeriod (UInt dutyCyclePeriod)
 Sets the duty cycle period. More...
 
Real getMaxBoost () const
 Returns the maximum boost value. More...
 
void setMaxBoost (Real maxBoost)
 Sets the maximum boost value. More...
 
UInt getIterationNum () const
 Returns the iteration number. More...
 
void setIterationNum (UInt iterationNum)
 Sets the iteration number. More...
 
UInt getIterationLearnNum () const
 Returns the learning iteration number. More...
 
void setIterationLearnNum (UInt iterationLearnNum)
 Sets the learning iteration number. More...
 
UInt getSpVerbosity () const
 Returns the verbosity level. More...
 
void setSpVerbosity (UInt spVerbosity)
 Sets the verbosity level. More...
 
bool getWrapAround () const
 Returns boolean value of wrapAround which indicates if receptive fields should wrap around from the beginning the input dimensions to the end. More...
 
void setWrapAround (bool wrapAround)
 Sets wrapAround. More...
 
UInt getUpdatePeriod () const
 Returns the update period. More...
 
void setUpdatePeriod (UInt updatePeriod)
 Sets the update period. More...
 
Real getSynPermTrimThreshold () const
 Returns the permanence trim threshold. More...
 
void setSynPermTrimThreshold (Real synPermTrimThreshold)
 Sets the permanence trim threshold. More...
 
Real getSynPermActiveInc () const
 Returns the permanence increment amount for active synapses inputs. More...
 
void setSynPermActiveInc (Real synPermActiveInc)
 Sets the permanence increment amount for active synapses inputs. More...
 
Real getSynPermInactiveDec () const
 Returns the permanence decrement amount for inactive synapses. More...
 
void setSynPermInactiveDec (Real synPermInactiveDec)
 Returns the permanence decrement amount for inactive synapses. More...
 
Real getSynPermBelowStimulusInc () const
 Returns the permanence increment amount for columns that have not been recently active. More...
 
void setSynPermBelowStimulusInc (Real synPermBelowStimulusInc)
 Sets the permanence increment amount for columns that have not been recently active. More...
 
Real getSynPermConnected () const
 Returns the permanence amount that qualifies a synapse as being connected. More...
 
void setSynPermConnected (Real synPermConnected)
 Sets the permanence amount that qualifies a synapse as being connected. More...
 
Real getSynPermMax () const
 Returns the maximum permanence amount a synapse can achieve. More...
 
void setSynPermMax (Real synPermMax)
 Sets the maximum permanence amount a synapse can achieve. More...
 
Real getMinPctOverlapDutyCycles () const
 Returns the minimum tolerated overlaps, given as percent of neighbors overlap score. More...
 
void setMinPctOverlapDutyCycles (Real minPctOverlapDutyCycles)
 Sets the minimum tolerated overlaps, given as percent of neighbors overlap score. More...
 
Real getMinPctActiveDutyCycles () const
 Returns the minimum tolerated activity duty cycle, given as percent of neighbors' activity duty cycle. More...
 
void setMinPctActiveDutyCycles (Real minPctActiveDutyCycles)
 Sets the minimum tolerated activity duty cycle, given as percent of neighbors' activity duty cycle. More...
 
void getBoostFactors (Real boostFactors[]) const
 Returns the boost factors for all columns. More...
 
void setBoostFactors (Real boostFactors[])
 Sets the boost factors for all columns. More...
 
void getOverlapDutyCycles (Real overlapDutyCycles[]) const
 Returns the overlap duty cycles for all columns. More...
 
void setOverlapDutyCycles (Real overlapDutyCycles[])
 Sets the overlap duty cycles for all columns. More...
 
void getActiveDutyCycles (Real activeDutyCycles[]) const
 Returns the activity duty cycles for all columns. More...
 
void setActiveDutyCycles (Real activeDutyCycles[])
 Sets the activity duty cycles for all columns. More...
 
void getMinOverlapDutyCycles (Real minOverlapDutyCycles[]) const
 Returns the minimum overlap duty cycles for all columns. More...
 
void setMinOverlapDutyCycles (Real minOverlapDutyCycles[])
 Sets the minimum overlap duty cycles for all columns. More...
 
void getMinActiveDutyCycles (Real minActiveDutyCycles[]) const
 Returns the minimum activity duty cycles for all columns. More...
 
void setMinActiveDutyCycles (Real minActiveDutyCycles[])
 Sets the minimum activity duty cycles for all columns. More...
 
void getPotential (UInt column, UInt potential[]) const
 Returns the potential mapping for a given column. More...
 
void setPotential (UInt column, UInt potential[])
 Sets the potential mapping for a given column. More...
 
void getPermanence (UInt column, Real permanence[]) const
 Returns the permanence values for a given column. More...
 
void setPermanence (UInt column, Real permanence[])
 Sets the permanence values for a given column. More...
 
void getConnectedSynapses (UInt column, UInt connectedSynapses[]) const
 Returns the connected synapses for a given column. More...
 
void getConnectedCounts (UInt connectedCounts[]) const
 Returns the number of connected synapses for all columns. More...
 
void printParameters () const
 Print the main SP creation parameters to stdout.
 
UInt mapColumn_ (UInt column)
 Maps a column to its respective input index, keeping to the topology of the region. More...
 
vector< UIntmapPotential_ (UInt column, bool wrapAround)
 Maps a column to its input bits. More...
 
Real initPermConnected_ ()
 Returns a randomly generated permanence value for a synapses that is initialized in a connected state. More...
 
Real initPermNonConnected_ ()
 Returns a randomly generated permanence value for a synapses that is to be initialized in a non-connected state. More...
 
vector< RealinitPermanence_ (vector< UInt > &potential, Real connectedPct)
 Initializes the permanences of a column. More...
 
void updatePermanencesForColumn_ (vector< Real > &perm, UInt column, bool raisePerm=true)
 This method updates the permanence matrix with a column's new permanence values. More...
 
void calculateOverlap_ (UInt inputVector[], vector< UInt > &overlap)
 This function determines each column's overlap with the current input vector. More...
 
void inhibitColumns_ (vector< Real > &overlaps, vector< UInt > &activeColumns)
 Performs inhibition. More...
 
void inhibitColumnsGlobal_ (vector< Real > &overlaps, Real density, vector< UInt > &activeColumns)
 Perform global inhibition. More...
 
void inhibitColumnsLocal_ (vector< Real > &overlaps, Real density, vector< UInt > &activeColumns)
 Performs local inhibition. More...
 
void getNeighbors1D_ (UInt column, vector< UInt > &dimensions, UInt radius, bool wrapAround, vector< UInt > &neighbors)
 Returns a list of indices corresponding to the neighbors of a given column. More...
 
void getNeighbors2D_ (UInt column, vector< UInt > &dimensions, UInt radius, bool wrapAround, vector< UInt > &neighbors)
 Returns a list of indices corresponding to the neighbors of a given column. More...
 
void getNeighborsND_ (UInt column, vector< UInt > &dimensions, UInt radius, bool wrapAround, vector< UInt > &neighbors)
 Similar to _getNeighbors1D and _getNeighbors2D, this function returns a list of indices corresponding to the neighbors of a given column. More...
 
void adaptSynapses_ (UInt inputVector[], vector< UInt > &activeColumns)
 The primary method in charge of learning. More...
 
void bumpUpWeakColumns_ ()
 This method increases the permanence values of synapses of columns whose activity level has been too low. More...
 
void updateInhibitionRadius_ ()
 Update the inhibition radius. More...
 
Real avgColumnsPerInput_ ()
 REturns the average number of columns per input, taking into account the topology of the inputs and columns. More...
 
Real avgConnectedSpanForColumn1D_ (UInt column)
 The range of connected synapses for column. More...
 
Real avgConnectedSpanForColumn2D_ (UInt column)
 The range of connectedSynapses per column, averaged for each dimension. More...
 
Real avgConnectedSpanForColumnND_ (UInt column)
 The range of connectedSynapses per column, averaged for each dimension. More...
 
void updateMinDutyCycles_ ()
 Updates the minimum duty cycles defining normal activity for a column. More...
 
void updateMinDutyCyclesGlobal_ ()
 Updates the minimum duty cycles in a global fashion. More...
 
void updateMinDutyCyclesLocal_ ()
 Updates the minimum duty cycles. More...
 
void updateDutyCycles_ (vector< UInt > &overlaps, UInt activeArray[])
 Updates the duty cycles for each column. More...
 
void updateBoostFactors_ ()
 Update the boost factors for all columns. More...
 
void updateBookeepingVars_ (bool learn)
 Updates counter instance variables each round. More...
 
bool isUpdateRound_ ()
 
void seed_ (UInt64 seed)
 Initialize the random seed. More...
 
void printState (vector< UInt > &state)
 Print the given UInt array in a nice format.
 
void printState (vector< Real > &state)
 Print the given Real array in a nice format.
 

Static Public Member Functions

static void updateDutyCyclesHelper_ (vector< Real > &dutyCycles, vector< UInt > &newValues, UInt period)
 Updates a duty cycle estimate with a new value. More...
 

Detailed Description

CLA spatial pooler implementation in C++.

Description

The Spatial Pooler is responsible for creating a sparse distributed representation of the input. Given an input it computes a set of sparse active columns and simultaneously updates its permanences, duty cycles, etc.

The primary public interfaces to this function are the "initialize" and "compute" methods.

Example usage:

SpatialPooler sp;
sp.initialize(inputDimensions, columnDimensions, <parameters>);
while (true) {
   <get input vector>
   sp.compute(inputVector, learn, activeColumns)
   <do something with output>

Definition at line 69 of file SpatialPooler.hpp.

Member Function Documentation

void nupic::algorithms::spatial_pooler::SpatialPooler::adaptSynapses_ ( UInt  inputVector[],
vector< UInt > &  activeColumns 
)

The primary method in charge of learning.

Adapts the permanence values of the synapses based on the input vector, and the chosen columns after inhibition round. Permanence values are increased for synapses connected to input bits that are turned on, and decreased for synapses connected to inputs bits that are turned off.


Parameters
inputVectoran int array of 0's and 1's that comprises the input to the spatial pooler. There exists an entry in the array for every input bit.
activeColumnsan int vector containing the indices of the columns that survived inhibition.
Real nupic::algorithms::spatial_pooler::SpatialPooler::avgColumnsPerInput_ ( )

REturns the average number of columns per input, taking into account the topology of the inputs and columns.

This value is used to calculate the inhibition radius. This function supports an arbitrary number of dimensions. If the number of column dimensions does not match the number of input dimensions, we treat the missing, or phantom dimensions as 'ones'.

Returns
real number of the average number of columns per input.
Real nupic::algorithms::spatial_pooler::SpatialPooler::avgConnectedSpanForColumn1D_ ( UInt  column)

The range of connected synapses for column.

This is used to calculate the inhibition radius. This variation of the function only supports a 1 dimensional column toplogy.

Parameters
columnAn int number identifying a column in the permanence, potential and connectivity matrices.
Real nupic::algorithms::spatial_pooler::SpatialPooler::avgConnectedSpanForColumn2D_ ( UInt  column)

The range of connectedSynapses per column, averaged for each dimension.

This vaule is used to calculate the inhibition radius. This variation of the function only supports a 2 dimensional column topology.

Parameters
columnAn int number identifying a column in the permanence, potential and connectivity matrices.
Real nupic::algorithms::spatial_pooler::SpatialPooler::avgConnectedSpanForColumnND_ ( UInt  column)

The range of connectedSynapses per column, averaged for each dimension.

This vaule is used to calculate the inhibition radius. This variation of the function supports arbitrary column dimensions.

Parameters
columnAn int number identifying a column in the permanence, potential and connectivity matrices.
void nupic::algorithms::spatial_pooler::SpatialPooler::bumpUpWeakColumns_ ( )

This method increases the permanence values of synapses of columns whose activity level has been too low.

Such columns are identified by having an overlap duty cycle that drops too much below those of their peers. The permanence values for such columns are increased.

void nupic::algorithms::spatial_pooler::SpatialPooler::calculateOverlap_ ( UInt  inputVector[],
vector< UInt > &  overlap 
)

This function determines each column's overlap with the current input vector.

The overlap of a column is the number of synapses for that column that are connected (permance value is greater than '_synPermConnected') to input bits which are turned on. Overlap values that are lower than the 'stimulusThreshold' are ignored. The implementation takes advantage of the SpraseBinaryMatrix class to perform this calculation efficiently.

Parameters
inputVectora int array of 0's and 1's that comprises the input to the spatial pooler.
overlapan int vector containing the overlap score for each column. The overlap score for a column is defined as the number of synapses in a "connected state" (connected synapses) that are connected to input bits which are turned on.
virtual void nupic::algorithms::spatial_pooler::SpatialPooler::compute ( UInt  inputVector[],
bool  learn,
UInt  activeVector[] 
)
virtual

This is the main workshorse method of the SpatialPooler class.

This method takes an input vector and computes the set of output active columns. If 'learn' is set to True, this method also performs learning.

Parameters
inputVectorAn array of integer 0's and 1's that comprises the input to the spatial pooler. The length of the array must match the total number of input bits implied by the constructor (also returned by the method getNumInputs). In cases where the input is multi-dimensional, inputVector is a flattened array of inputs.
learnA boolean value indicating whether learning should be performed. Learning entails updating the permanence values of the synapses, duty cycles, etc. Learning is typically on but setting learning to 'off' is useful for analyzing the current state of the SP. For example, you might want to feed in various inputs and examine the resulting SDR's. Note that if learning is off, boosting is turned off and columns that have never won will be removed from activeVector. TODO: we may want to keep boosting on even when learning is off.
activeVectorAn array representing the winning columns after inhibition. The size of the array is equal to the number of columns (also returned by the method getNumColumns). This array will be populated with 1's at the indices of the active columns, and 0's everywhere else. In the case where the output is multi-dimensional, activeVector represents a flattened array of outputs.
void nupic::algorithms::spatial_pooler::SpatialPooler::getActiveDutyCycles ( Real  activeDutyCycles[]) const

Returns the activity duty cycles for all columns.

'activeDutyCycles' size must match the number of columns.

Parameters
activeDutyCyclesreal array to store activity duty cycles for all columns.
void nupic::algorithms::spatial_pooler::SpatialPooler::getBoostFactors ( Real  boostFactors[]) const

Returns the boost factors for all columns.

'boostFactors' size must match the number of columns.

Parameters
boostFactorsreal array to store boost factors of all columns.
vector<UInt> nupic::algorithms::spatial_pooler::SpatialPooler::getColumnDimensions ( ) const

Returns the dimensions of the columns in the region.

Returns
Integer number of column dimension.
void nupic::algorithms::spatial_pooler::SpatialPooler::getConnectedCounts ( UInt  connectedCounts[]) const

Returns the number of connected synapses for all columns.

'connectedCounts' size must match the number of columns.

Parameters
connectedCountsinteger array to store the connected synapses for all columns.
void nupic::algorithms::spatial_pooler::SpatialPooler::getConnectedSynapses ( UInt  column,
UInt  connectedSynapses[] 
) const

Returns the connected synapses for a given column.

'connectedSynapses' size must match the number of inputs.

Parameters
columninteger of column index.
connectedSynapsesinteger array to store the connected synapses for a given column.
UInt nupic::algorithms::spatial_pooler::SpatialPooler::getDutyCyclePeriod ( ) const

Returns the duty cycle period.

Returns
integer of duty cycle period.
bool nupic::algorithms::spatial_pooler::SpatialPooler::getGlobalInhibition ( ) const
Returns
boolen value of whether global inhibition is enabled.
UInt nupic::algorithms::spatial_pooler::SpatialPooler::getInhibitionRadius ( ) const

Returns the inhibition radius.

Returns
(positive) integer of inhibition radius/
vector<UInt> nupic::algorithms::spatial_pooler::SpatialPooler::getInputDimensions ( ) const

Returns the dimensions of the input vector.

Returns
Integer vector of input dimension.
UInt nupic::algorithms::spatial_pooler::SpatialPooler::getIterationLearnNum ( ) const

Returns the learning iteration number.

Returns
integer of the learning iteration number.
UInt nupic::algorithms::spatial_pooler::SpatialPooler::getIterationNum ( ) const

Returns the iteration number.

Returns
integer number of iteration number.
Real nupic::algorithms::spatial_pooler::SpatialPooler::getLocalAreaDensity ( ) const

Returns the local area density.

Returns a value less than 0 if parameter is unused".

Returns
real number of local area density.
Real nupic::algorithms::spatial_pooler::SpatialPooler::getMaxBoost ( ) const

Returns the maximum boost value.

Returns
real number of the maximum boost value.
void nupic::algorithms::spatial_pooler::SpatialPooler::getMinActiveDutyCycles ( Real  minActiveDutyCycles[]) const

Returns the minimum activity duty cycles for all columns.

'_minActiveDutyCycles' size must match the number of columns.

Parameters
minActiveDutyCyclesreal array to store the minimum activity duty cycles for all columns.
void nupic::algorithms::spatial_pooler::SpatialPooler::getMinOverlapDutyCycles ( Real  minOverlapDutyCycles[]) const

Returns the minimum overlap duty cycles for all columns.

Parameters
minOverlapDutyCyclesreal arry to store mininum overlap duty cycles for all columns. 'minOverlapDutyCycles' size must match the number of columns.
Real nupic::algorithms::spatial_pooler::SpatialPooler::getMinPctActiveDutyCycles ( ) const

Returns the minimum tolerated activity duty cycle, given as percent of neighbors' activity duty cycle.

Returns
minPctOverlapDutyCycles real number of the minimum tolerated activity duty cycle.
Real nupic::algorithms::spatial_pooler::SpatialPooler::getMinPctOverlapDutyCycles ( ) const

Returns the minimum tolerated overlaps, given as percent of neighbors overlap score.

Returns
real number of the minimum tolerated overlaps.
void nupic::algorithms::spatial_pooler::SpatialPooler::getNeighbors1D_ ( UInt  column,
vector< UInt > &  dimensions,
UInt  radius,
bool  wrapAround,
vector< UInt > &  neighbors 
)

Returns a list of indices corresponding to the neighbors of a given column.

In this variation of the method, which only supports a one dimensional column toplogy, a column's neighbors are those neighbors who are 'radius' indices away. This information is needed to perform inhibition. This method is a subset of _getNeighborsND and is only included for illustration purposes, and potentially enhanced performance for spatial pooler implementations that only require a one-dimensional topology.


Parameters
columnAn integer number. The index identifying a column in the permanence, potential and connectivity matrices.
dimensionsAn int array containg a dimensions for the column space. A 2x3 grid will be represented by [2,3].
radiusAn integer number Indicates how far away from a given column are other columns to be considered its neighbors. In the previous 2x3 example, each column with coordinates: [2+/-radius, 3+/-radius] is considered a neighbor.
wrapAroundA boolean value indicating whether to consider columns at the border of a dimensions to be adjacent to columns at the other end of the dimension. For example, if the columns are layed out in one deimnsion, columns 1 and 10 will be considered adjacent if wrapAround is set to true: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].
neighborsAn int arrayof indices corresponding to the neighbors of a given column.
void nupic::algorithms::spatial_pooler::SpatialPooler::getNeighbors2D_ ( UInt  column,
vector< UInt > &  dimensions,
UInt  radius,
bool  wrapAround,
vector< UInt > &  neighbors 
)

Returns a list of indices corresponding to the neighbors of a given column.

Since the permanence values are stored in such a way that information about toplogy is lost, this method allows for reconstructing the toplogy of the inputs, which are flattened to one array. Given a column's index, its neighbors are defined as those columns that are 'radius' indices away from it in each dimension. The method returns a list of the flat indices of these columns. This method is a subset of _getNeighborsND and is only included for illustration purposes, and potentially enhanced performance for spatial pooler implementations that only require a two-dimensional topology.

Parameters
columnAn integer number. The index identifying a column in the permanence, potential and connectivity matrices.
dimensionsAn int array containg a dimensions for the column space. A 2x3 grid will be represented by [2,3].
radiusAn integer number Indicates how far away from a given column are other columns to be considered its neighbors. In the previous 2x3 example, each column with coordinates: [2+/-radius, 3+/-radius] is considered a neighbor.
wrapAroundA boolean value indicating whether to consider columns at the border of a dimensions to be adjacent to columns at the other end of the dimension. For example, if the columns are layed out in one deimnsion, columns 1 and 10 will be considered adjacent if wrapAround is set to true: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].
neighborsAn int array of indices corresponding to the neighbors of a given column.
void nupic::algorithms::spatial_pooler::SpatialPooler::getNeighborsND_ ( UInt  column,
vector< UInt > &  dimensions,
UInt  radius,
bool  wrapAround,
vector< UInt > &  neighbors 
)

Similar to _getNeighbors1D and _getNeighbors2D, this function returns a list of indices corresponding to the neighbors of a given column.

Since the permanence values are stored in such a way that information about toplogy is lost. This method allows for reconstructing the toplogy of the inputs, which are flattened to one array. Given a column's index, its neighbors are defined as those columns that are 'radius' indices away from it in each dimension. The method returns a list of the flat indices of these columns.


Parameters
columnAn integer number. The index identifying a column in the permanence, potential and connectivity matrices.
dimensionsAn int array containg a dimensions for the column space. A 2x3 grid will be represented by [2,3].
radiusAn integer number Indicates how far away from a given column are other columns to be considered its neighbors. In the previous 2x3 example, each column with coordinates: [2+/-radius, 3+/-radius] is considered a neighbor.
wrapAroundA boolean value indicating whether to consider columns at the border of a dimensions to be adjacent to columns at the other end of the dimension. For example, if the columns are layed out in one deimnsion, columns 1 and 10 will be considered adjacent if wrapAround is set to true: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].
neighborsAn int arrayof indices corresponding to the neighbors of a given column.
Int nupic::algorithms::spatial_pooler::SpatialPooler::getNumActiveColumnsPerInhArea ( ) const

Returns the number of active columns per inhibition area.

Returns
integer number of active columns per inhbition area, Returns a value less than 0 if parameter is unuse.
UInt nupic::algorithms::spatial_pooler::SpatialPooler::getNumColumns ( ) const

Returns the total number of columns.

Returns
Integer number of column numbers.
UInt nupic::algorithms::spatial_pooler::SpatialPooler::getNumInputs ( ) const

Returns the total number of inputs.

Returns
Integer number of inputs.
void nupic::algorithms::spatial_pooler::SpatialPooler::getOverlapDutyCycles ( Real  overlapDutyCycles[]) const

Returns the overlap duty cycles for all columns.

'overlapDutyCycles' size must match the number of columns.

Parameters
overlapDutyCyclesreal array to store overlap duty cycles for all columns.
void nupic::algorithms::spatial_pooler::SpatialPooler::getPermanence ( UInt  column,
Real  permanence[] 
) const

Returns the permanence values for a given column.

'permanence' size must match the number of inputs.

Parameters
columninteger of column index.
permanencereal array to store permanence values for the selected column.
void nupic::algorithms::spatial_pooler::SpatialPooler::getPotential ( UInt  column,
UInt  potential[] 
) const

Returns the potential mapping for a given column.

'potential' size must match the number of inputs.

Parameters
columninteger of column index.
potentialinteger array of potential mapping for the selected column.
Real nupic::algorithms::spatial_pooler::SpatialPooler::getPotentialPct ( ) const

Returns the potential percent.

Returns
real number of the potential percent.
UInt nupic::algorithms::spatial_pooler::SpatialPooler::getPotentialRadius ( ) const

Returns the potential radius.

Returns
Integer number of potential radius.
UInt nupic::algorithms::spatial_pooler::SpatialPooler::getSpVerbosity ( ) const

Returns the verbosity level.

Returns
integer of the verbosity level.
UInt nupic::algorithms::spatial_pooler::SpatialPooler::getStimulusThreshold ( ) const

Returns the stimulus threshold.

Returns
integer number of stimulus threshold.
Real nupic::algorithms::spatial_pooler::SpatialPooler::getSynPermActiveInc ( ) const

Returns the permanence increment amount for active synapses inputs.

Returns
real number of the permanence increment amount for active synapses inputs.
Real nupic::algorithms::spatial_pooler::SpatialPooler::getSynPermBelowStimulusInc ( ) const

Returns the permanence increment amount for columns that have not been recently active.

Returns
positive real number of the permanence increment amount for columns that have not been recently active.
Real nupic::algorithms::spatial_pooler::SpatialPooler::getSynPermConnected ( ) const

Returns the permanence amount that qualifies a synapse as being connected.

Returns
real number of the permanence amount that qualifies a synapse as being connected.
Real nupic::algorithms::spatial_pooler::SpatialPooler::getSynPermInactiveDec ( ) const

Returns the permanence decrement amount for inactive synapses.

Returns
real number of the permanence decrement amount for inactive synapses.
Real nupic::algorithms::spatial_pooler::SpatialPooler::getSynPermMax ( ) const

Returns the maximum permanence amount a synapse can achieve.

Returns
real number of the max permanence amount.
Real nupic::algorithms::spatial_pooler::SpatialPooler::getSynPermTrimThreshold ( ) const

Returns the permanence trim threshold.

Returns
real number of the permanence trim threshold.
UInt nupic::algorithms::spatial_pooler::SpatialPooler::getUpdatePeriod ( ) const

Returns the update period.

Returns
integer of update period.
bool nupic::algorithms::spatial_pooler::SpatialPooler::getWrapAround ( ) const

Returns boolean value of wrapAround which indicates if receptive fields should wrap around from the beginning the input dimensions to the end.

Returns
the boolean value of wrapAround.
void nupic::algorithms::spatial_pooler::SpatialPooler::inhibitColumns_ ( vector< Real > &  overlaps,
vector< UInt > &  activeColumns 
)

Performs inhibition.

This method calculates the necessary values needed to actually perform inhibition and then delegates the task of picking the active columns to helper functions.

Parameters
overlapsan array containing the overlap score for each column. The overlap score for a column is defined as the number of synapses in a "connected state" (connected synapses) that are connected to input bits which are turned on.
activeColumnsan int array containing the indices of the active columns.
void nupic::algorithms::spatial_pooler::SpatialPooler::inhibitColumnsGlobal_ ( vector< Real > &  overlaps,
Real  density,
vector< UInt > &  activeColumns 
)

Perform global inhibition.

Performing global inhibition entails picking the top 'numActive' columns with the highest overlap score in the entire region. At most half of the columns in a local neighborhood are allowed to be active.

Parameters
overlapsa real array containing the overlap score for each column. The overlap score for a column is defined as the number of synapses in a "connected state" (connected synapses) that are connected to input bits which are turned on.
densitya real number of the fraction of columns to survive inhibition.
activeColumnsan int array containing the indices of the active columns.
void nupic::algorithms::spatial_pooler::SpatialPooler::inhibitColumnsLocal_ ( vector< Real > &  overlaps,
Real  density,
vector< UInt > &  activeColumns 
)

Performs local inhibition.

Local inhibition is performed on a column by column basis. Each column observes the overlaps of its neighbors and is selected if its overlap score is within the top 'numActive' in its local neighborhood. At most half of the columns in a local neighborhood are allowed to be active.


Parameters
overlapsan array containing the overlap score for each column. The overlap score for a column is defined as the number of synapses in a "connected state" (connected synapses) that are connected to input bits which are turned on.
densityThe fraction of columns to survive inhibition. This value is only an intended target. Since the surviving columns are picked in a local fashion, the exact fraction of survining columns is likely to vary.
activeColumnsan int array containing the indices of the active columns.
virtual void nupic::algorithms::spatial_pooler::SpatialPooler::initialize ( vector< UInt inputDimensions,
vector< UInt columnDimensions,
UInt  potentialRadius = 16,
Real  potentialPct = 0.5,
bool  globalInhibition = true,
Real  localAreaDensity = -1.0,
UInt  numActiveColumnsPerInhArea = 10,
UInt  stimulusThreshold = 0,
Real  synPermInactiveDec = 0.01,
Real  synPermActiveInc = 0.1,
Real  synPermConnected = 0.1,
Real  minPctOverlapDutyCycles = 0.001,
Real  minPctActiveDutyCycles = 0.001,
UInt  dutyCyclePeriod = 1000,
Real  maxBoost = 10.0,
Int  seed = 1,
UInt  spVerbosity = 0,
bool  wrapAround = true 
)
virtual

Initialize the spatial pooler using the given parameters.

Parameters
inputDimensionsA list of integers 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 dimesion with 100 inputs use [100]. For a two dimensional topology of 10x5 use [10,5].
columnDimensionsA list of integers 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 dimesion with 2000 columns use 2000, or [2000]. For a three dimensional topology of 32x64x16 use [32, 64, 16].
potentialRadiusThis parameter deteremines 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 'receptive field' 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).
potentialPctThe 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.
globalInhibitionIf 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 resepct to their local neighborhoods. Global inhibition boosts performance significantly but there is no topology at the output.
localAreaDensityThe 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). If localAreaDensity is set to a negative value output sparsity will be determined by the numActivePerInhArea.
numActiveColumnsPerInhAreaAn alternate way to control the sparsity of active columns. If numActivePerInhArea is specified then localAreaDensity must be less than 0, and vice versa. When numActivePerInhArea > 0, the inhibition logic will insure that at most 'numActivePerInhArea' columns remain ON within a local inhibition area (the size of which is set by the internally calculated inhibitionRadius). 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.
stimulusThresholdThis is a number specifying the minimum number of synapses that must be active in order for a column to turn ON. The purpose of this is to prevent noisy input from activating columns.
synPermInactiveDecThe amount by which the permanence of an inactive synapse is decremented in each learning step.
synPermActiveIncThe amount by which the permanence of an active synapse is incremented in each round.
synPermConnectedThe 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.
minPctOverlapDutyCyclesA 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 column 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 sub-par 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.
minPctActiveDutyCyclesA 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.

Parameters
dutyCyclePeriodThe period used to calculate duty cycles. Higher values make it take longer to respond to changes in boost. Shorter values make it potentially more unstable and likely to oscillate.
maxBoostThe 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 a 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.
seedSeed for our random number generator. If seed is < 0 a randomly generated seed is used. The behavior of the spatial pooler is deterministic once the seed is set.
spVerbosityspVerbosity level: 0, 1, 2, or 3
wrapAroundboolean value that determines whether or not inputs at the beginning and end of an input dimension are considered neighbors for the purpose of mapping inputs to columns.
vector<Real> nupic::algorithms::spatial_pooler::SpatialPooler::initPermanence_ ( vector< UInt > &  potential,
Real  connectedPct 
)

Initializes the permanences of a column.

The method returns a 1-D array the size of the input, where each entry in the array represents the initial permanence value between the input bit at the particular index in the array, and the column represented by the 'index' parameter.

Parameters
potentialA int vector specifying the potential pool of the column. Permanence values will only be generated for input bits

corresponding to indices for which the mask value is 1.

Parameters
connectedPctA real value between 0 or 1 specifying the percent of the input bits that will start off in a connected state.
Real nupic::algorithms::spatial_pooler::SpatialPooler::initPermConnected_ ( )

Returns a randomly generated permanence value for a synapses that is initialized in a connected state.

The basic idea here is to initialize permanence values very close to synPermConnected so that a small number of learning steps could make it disconnected or connected.

Note: experimentation was done a long time ago on the best way to initialize permanence values, but the history for this particular scheme has been lost.

Returns
real number of a randomly generated permanence value for a synapses that is initialized in a connected state.
Real nupic::algorithms::spatial_pooler::SpatialPooler::initPermNonConnected_ ( )

Returns a randomly generated permanence value for a synapses that is to be initialized in a non-connected state.

Returns
real number of a randomly generated permanence value for a synapses that is to be initialized in a non-connected state.
bool nupic::algorithms::spatial_pooler::SpatialPooler::isUpdateRound_ ( )
Returns
boolean value indicating whether enough rounds have passed to warrant updates of duty cycles
virtual void nupic::algorithms::spatial_pooler::SpatialPooler::load ( istream &  inStream)
virtual

Load (deserialize) and initialize the spatial pooler from the specified input stream.

Parameters
inStreamA valid istream.
UInt nupic::algorithms::spatial_pooler::SpatialPooler::mapColumn_ ( UInt  column)

Maps a column to its respective input index, keeping to the topology of the region.

It takes the index of the column as an argument and determines what is the index of the flattened input vector that is to be the center of the column's potential pool. It distributes the columns over the inputs uniformly. The return value is an integer representing the index of the input bit. Examples of the expected output of this method: If the topology is one dimensional, and the column index is 0, this method will return the input index 0. If the column index is 1, and there are 3 columns over 7 inputs, this method will return the input index 3. If the topology is two dimensional, with column dimensions [3, 5] and input dimensions [7, 11], and the column index is 3, the method returns input index 8.


Parameters
indexThe index identifying a column in the permanence, potential and connectivity matrices.
wrapAroundA boolean value indicating that boundaries should be ignored.
vector<UInt> nupic::algorithms::spatial_pooler::SpatialPooler::mapPotential_ ( UInt  column,
bool  wrapAround 
)

Maps a column to its input bits.

This method encapsultes the topology of the region. It takes the index of the column as an argument and determines what are the indices of the input vector that are located within the column's potential pool. The return value is a list containing the indices of the input bits. The current implementation of the base class only supports a 1 dimensional topology of columsn with a 1 dimensional topology of inputs. To extend this class to support 2-D topology you will need to override this method. Examples of the expected output of this method: If the potentialRadius is greater than or equal to the entire input space, (global visibility), then this method returns an array filled with all the indices If the topology is one dimensional, and the potentialRadius is 5, this method will return an array containing 5 consecutive values centered on the index of the column (wrapping around if necessary). If the topology is two dimensional (not implemented), and the potentialRadius is 5, the method should return an array containing 25 '1's, where the exact indices are to be determined by the mapping from 1-D index to 2-D position.


Parameters
columnAn int index identifying a column in the permanence, potential and connectivity matrices.
wrapAroundA boolean value indicating that boundaries should be region boundaries ignored.
virtual UInt nupic::algorithms::spatial_pooler::SpatialPooler::persistentSize ( ) const
virtual

Returns the number of bytes that a save operation would result in.

Note: this method is currently somewhat inefficient as it just does a full save into an ostream and counts the resulting size.

Returns
Integer number of bytes
virtual void nupic::algorithms::spatial_pooler::SpatialPooler::save ( ostream &  outStream) const
virtual

Save (serialize) the current state of the spatial pooler to the specified file.

Parameters
fdA valid file descriptor.
void nupic::algorithms::spatial_pooler::SpatialPooler::seed_ ( UInt64  seed)

Initialize the random seed.

Parameters
seed64bit int of random seed
void nupic::algorithms::spatial_pooler::SpatialPooler::setActiveDutyCycles ( Real  activeDutyCycles[])

Sets the activity duty cycles for all columns.

'activeDutyCycles' size must match the number of columns.

Parameters
activeDutyCyclesreal array of the activity duty cycles for all columns.
void nupic::algorithms::spatial_pooler::SpatialPooler::setBoostFactors ( Real  boostFactors[])

Sets the boost factors for all columns.

'boostFactors' size must match the number of columns.

Parameters
boostFactorsreal array of boost factors of all columns.
void nupic::algorithms::spatial_pooler::SpatialPooler::setDutyCyclePeriod ( UInt  dutyCyclePeriod)

Sets the duty cycle period.

Parameters
dutyCyclePeriodinteger number of duty cycle period.
void nupic::algorithms::spatial_pooler::SpatialPooler::setGlobalInhibition ( bool  globalInhibition)

Sets global inhibition.

Parameters
globalInhibitionboolen varable of whether global inhibition is enabled.
void nupic::algorithms::spatial_pooler::SpatialPooler::setInhibitionRadius ( UInt  inhibitionRadius)

Sets the inhibition radius.

Parameters
inhibitionRadiusinteger of inhibition radius.
void nupic::algorithms::spatial_pooler::SpatialPooler::setIterationLearnNum ( UInt  iterationLearnNum)

Sets the learning iteration number.

Parameters
iterationLearnNuminteger of learning iteration number.
void nupic::algorithms::spatial_pooler::SpatialPooler::setIterationNum ( UInt  iterationNum)

Sets the iteration number.

Parameters
iterationNuminteger number of iteration number.
void nupic::algorithms::spatial_pooler::SpatialPooler::setLocalAreaDensity ( Real  localAreaDensity)

Sets the local area density.

Invalidates the 'numActivePerInhArea' parameter".

Parameters
localAreaDensityreal number of local area density.
void nupic::algorithms::spatial_pooler::SpatialPooler::setMaxBoost ( Real  maxBoost)

Sets the maximum boost value.

Parameters
maxBoostreal number of maximum boost value, must be larger than 1.0
void nupic::algorithms::spatial_pooler::SpatialPooler::setMinActiveDutyCycles ( Real  minActiveDutyCycles[])

Sets the minimum activity duty cycles for all columns.

'_minActiveDutyCycles' size must match the number of columns.

Parameters
minActiveDutyCyclesreal array of the minimum activity duty cycles for all columns.
void nupic::algorithms::spatial_pooler::SpatialPooler::setMinOverlapDutyCycles ( Real  minOverlapDutyCycles[])

Sets the minimum overlap duty cycles for all columns.

'_minOverlapDutyCycles' size must match the number of columns.

Parameters
minOverlapDutyCyclesreal array of the minimum overlap duty cycles for all columns.
void nupic::algorithms::spatial_pooler::SpatialPooler::setMinPctActiveDutyCycles ( Real  minPctActiveDutyCycles)

Sets the minimum tolerated activity duty cycle, given as percent of neighbors' activity duty cycle.

Parameters
minPctActiveDutyCyclesreal number of the minimum tolerated activity duty cycle.
void nupic::algorithms::spatial_pooler::SpatialPooler::setMinPctOverlapDutyCycles ( Real  minPctOverlapDutyCycles)

Sets the minimum tolerated overlaps, given as percent of neighbors overlap score.

Parameters
minPctOverlapDutyCyclesreal number of the minimum tolerated overlaps.
void nupic::algorithms::spatial_pooler::SpatialPooler::setNumActiveColumnsPerInhArea ( UInt  numActiveColumnsPerInhArea)

Sets the number of active columns per inhibition area.

Invalidates the 'localAreaDensity' parameter.

Parameters
numActiveColumnsPerInhAreainteger number of active columns per inhibition area.
void nupic::algorithms::spatial_pooler::SpatialPooler::setOverlapDutyCycles ( Real  overlapDutyCycles[])

Sets the overlap duty cycles for all columns.

'overlapDutyCycles' size must match the number of columns.

Parameters
overlapDutyCyclesreal array of the overlap duty cycles for all columns.
void nupic::algorithms::spatial_pooler::SpatialPooler::setPermanence ( UInt  column,
Real  permanence[] 
)

Sets the permanence values for a given column.

'permanence' size must match the number of inputs.

Parameters
columninteger of column index.
permanencereal array of permanence values for the selected column.
void nupic::algorithms::spatial_pooler::SpatialPooler::setPotential ( UInt  column,
UInt  potential[] 
)

Sets the potential mapping for a given column.

'potential' size must match the number of inputs.

Parameters
columninteger of column index.
potentialinteger array of potential mapping for the selected column.
void nupic::algorithms::spatial_pooler::SpatialPooler::setPotentialPct ( Real  potentialPct)

Sets the potential percent.

Parameters
potentialPctreal number of potential percent.
void nupic::algorithms::spatial_pooler::SpatialPooler::setPotentialRadius ( UInt  potentialRadius)

Sets the potential radius.

Parameters
potentialRadiusinteger number of potential raduis.
void nupic::algorithms::spatial_pooler::SpatialPooler::setSpVerbosity ( UInt  spVerbosity)

Sets the verbosity level.

Parameters
spVerbosityinteger of verbosity level.
void nupic::algorithms::spatial_pooler::SpatialPooler::setStimulusThreshold ( UInt  stimulusThreshold)

Sets the stimulus threshold.

Parameters
stimulusThreshold(positive) integer number of stimulus threshold
void nupic::algorithms::spatial_pooler::SpatialPooler::setSynPermActiveInc ( Real  synPermActiveInc)

Sets the permanence increment amount for active synapses inputs.

Parameters
synPermActiveIncreal number of the permanence increment amount for active synapses inputs, must be >0.
void nupic::algorithms::spatial_pooler::SpatialPooler::setSynPermBelowStimulusInc ( Real  synPermBelowStimulusInc)

Sets the permanence increment amount for columns that have not been recently active.

Parameters
synPermBelowStimulusIncreal number of the permanence increment amount for columns that have not been recently active, must be larger than 0.
void nupic::algorithms::spatial_pooler::SpatialPooler::setSynPermConnected ( Real  synPermConnected)

Sets the permanence amount that qualifies a synapse as being connected.

Parameters
synPermConnectedreal number of the permanence amount that qualifies a synapse as being connected.
void nupic::algorithms::spatial_pooler::SpatialPooler::setSynPermInactiveDec ( Real  synPermInactiveDec)

Returns the permanence decrement amount for inactive synapses.

Parameters
synPermInactiveDecreal number of the permanence decrement amount for inactive synapses.
void nupic::algorithms::spatial_pooler::SpatialPooler::setSynPermMax ( Real  synPermMax)

Sets the maximum permanence amount a synapse can achieve.

Parameters
synPermCMaxreal number of the maximum permanence amount that a synapse can achieve.
void nupic::algorithms::spatial_pooler::SpatialPooler::setSynPermTrimThreshold ( Real  synPermTrimThreshold)

Sets the permanence trim threshold.

Parameters
synPermTrimThresholdreal number of the permanence trim threshold.
void nupic::algorithms::spatial_pooler::SpatialPooler::setUpdatePeriod ( UInt  updatePeriod)

Sets the update period.

Parameters
updatePeriodinteger of update period.
void nupic::algorithms::spatial_pooler::SpatialPooler::setWrapAround ( bool  wrapAround)

Sets wrapAround.

Parameters
wrapAroundboolean value
void nupic::algorithms::spatial_pooler::SpatialPooler::stripUnlearnedColumns ( UInt  activeArray[]) const

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.

Parameters
activeArrayAn array of 1's and 0's representing winning columns calculated by the 'compute' method after disabling any columns that are not learned.
void nupic::algorithms::spatial_pooler::SpatialPooler::updateBookeepingVars_ ( bool  learn)

Updates counter instance variables each round.

Parameters
learna 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' might be useful for indicating separate training vs. testing sets.
void nupic::algorithms::spatial_pooler::SpatialPooler::updateBoostFactors_ ( )

Update the boost factors for all columns.

The boost factors are used to increase the overlap of inactive columns to improve their chances of becoming active. and hence encourage participation of more columns in the learning process. This is a line defined as: y = mx + b boost = (1-maxBoost)/minDuty * dutyCycle + maxFiringBoost. Intuitively this means that columns that have been active enough have a boost factor of 1, meaning their overlap is not boosted. Columns whose active duty cycle drops too much below that of their neighbors are boosted depending on how infrequently they have been active. The more infrequent, the more they are boosted. The exact boost factor is linearly interpolated between the points (dutyCycle:0, boost:maxFiringBoost) and (dutyCycle:minDuty, boost:1.0).

        boostFactor
            ^
maxBoost _  |
            |\
            | \
      1  _  |  \ _ _ _ _ _ _ _
            |
            +--------------------> activeDutyCycle
               |
        minActiveDutyCycle
void nupic::algorithms::spatial_pooler::SpatialPooler::updateDutyCycles_ ( vector< UInt > &  overlaps,
UInt  activeArray[] 
)

Updates the duty cycles for each column.

The OVERLAP duty cycle is a moving average of the number of inputs which overlapped with the each column. The ACTIVITY duty cycles is a moving average of the frequency of activation for each column.

Parameters
overlapsan int vector containing the overlap score for each column. The overlap score for a column is defined as the number of synapses in a "connected state" (connected synapses) that are connected to input bits which are turned on.
activeArrayAn int array containing the indices of the active columns, the sprase set of columns which survived inhibition
static void nupic::algorithms::spatial_pooler::SpatialPooler::updateDutyCyclesHelper_ ( vector< Real > &  dutyCycles,
vector< UInt > &  newValues,
UInt  period 
)
static

Updates a duty cycle estimate with a new value.

This is a helper function that is used to update several duty cycle variables in the Column class, such as: overlapDutyCucle, activeDutyCycle, minPctDutyCycleBeforeInh, minPctDutyCycleAfterInh, etc. returns the updated duty cycle. Duty cycles are updated according to the following formula:

              (period - 1)*dutyCycle + newValue
  dutyCycle := ----------------------------------
                          period

Parameters
dutyCyclesA real array containing one or more duty cycle values that need to be updated.
newValuesA int vector used to update the duty cycle.
periodA int number indicating the period of the duty cycle
void nupic::algorithms::spatial_pooler::SpatialPooler::updateInhibitionRadius_ ( )

Update the inhibition radius.

The inhibition radius is a meausre of the square (or hypersquare) of columns that each a column is "conencted to" on average. Since columns are not connected to each other directly, we determine this quantity by first figuring out how many inputs a column is connected to, and then multiplying it by the total number of columns that exist for each input. For multiple dimension the aforementioned calculations are averaged over all dimensions of inputs and columns. This value is meaningless if global inhibition is enabled.

void nupic::algorithms::spatial_pooler::SpatialPooler::updateMinDutyCycles_ ( )

Updates the minimum duty cycles defining normal activity for a column.

A column with activity duty cycle below this minimum threshold is boosted.

void nupic::algorithms::spatial_pooler::SpatialPooler::updateMinDutyCyclesGlobal_ ( )

Updates the minimum duty cycles in a global fashion.

Sets the minimum duty cycles for the overlap and activation of all columns to be a percent of the maximum in the region, specified by minPctOverlapDutyCycle and minPctActiveDutyCycle respectively. Functionaly it is equivalent to _updateMinDutyCyclesLocal, but this function exploits the globalilty of the compuation to perform it in a straightforward, and more efficient manner.

void nupic::algorithms::spatial_pooler::SpatialPooler::updateMinDutyCyclesLocal_ ( )

Updates the minimum duty cycles.

The minimum duty cycles are determined locally. Each column's minimum duty cycles are set to be a percent of the maximum duty cycles in the column's neighborhood. Unlike _updateMinDutyCycles

void nupic::algorithms::spatial_pooler::SpatialPooler::updatePermanencesForColumn_ ( vector< Real > &  perm,
UInt  column,
bool  raisePerm = true 
)

This method updates the permanence matrix with a column's new permanence values.

The column is identified by its index, which reflects the row in the matrix, and the permanence is given in 'dense' form, i.e. a full arrray containing all the zeros as well as the non-zero values. It is in charge of implementing 'clipping' - ensuring that the permanence values are always between 0 and 1 - and 'trimming' - enforcing sparsity by zeroing out all permanence values below '_synPermTrimThreshold'. It also maintains the consistency between 'self._permanences' (the matrix storeing the permanence values), 'self._connectedSynapses', (the matrix storing the bits each column is connected to), and 'self._connectedCounts' (an array storing the number of input bits each column is connected to). Every method wishing to modify the permanence matrix should do so through this method.


Parameters
permAn int vector of permanence values for a column. The array is "dense", i.e. it contains an entry for each input bit, even if the permanence value is 0.
columnAn int number identifying a column in the permanence, potential and connectivity matrices.
raisePerma boolean value indicating whether the permanence values should be raised until a minimum number are synapses are in a connected state. Should be set to 'false' when a direct assignment is required.
virtual UInt nupic::algorithms::spatial_pooler::SpatialPooler::version ( ) const
inlinevirtual

Get the version number of this spatial pooler.

Returns
Integer version number.

Definition at line 297 of file SpatialPooler.hpp.


The documentation for this class was generated from the following file: