Skip to content

Commit be812dc

Browse files
committed
SP fixing tests to match the new added check for sparsity
1 parent eb204f4 commit be812dc

File tree

3 files changed

+122
-85
lines changed

3 files changed

+122
-85
lines changed

src/htm/algorithms/SpatialPooler.cpp

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -365,12 +365,22 @@ const vector<Real> &SpatialPooler::getBoostedOverlaps() const {
365365
}
366366

367367
void SpatialPooler::initialize(
368-
const vector<UInt> inputDimensions, const vector<UInt> columnDimensions,
369-
UInt potentialRadius, Real potentialPct, bool globalInhibition,
368+
const vector<UInt>& inputDimensions,
369+
const vector<UInt>& columnDimensions,
370+
UInt potentialRadius,
371+
Real potentialPct,
372+
bool globalInhibition,
370373
Real localAreaDensity,
371-
UInt stimulusThreshold, Real synPermInactiveDec, Real synPermActiveInc,
372-
Real synPermConnected, Real minPctOverlapDutyCycles, UInt dutyCyclePeriod,
373-
Real boostStrength, Int seed, UInt spVerbosity, bool wrapAround) {
374+
UInt stimulusThreshold,
375+
Real synPermInactiveDec,
376+
Real synPermActiveInc,
377+
Real synPermConnected,
378+
Real minPctOverlapDutyCycles,
379+
UInt dutyCyclePeriod,
380+
Real boostStrength,
381+
Int seed,
382+
UInt spVerbosity,
383+
bool wrapAround) {
374384

375385
numInputs_ = 1u;
376386
inputDimensions_.clear();
@@ -583,7 +593,7 @@ void SpatialPooler::updateInhibitionRadius_() {
583593

584594
void SpatialPooler::updateMinDutyCycles_() {
585595
if (globalInhibition_ ||
586-
inhibitionRadius_ >
596+
inhibitionRadius_ >=
587597
*max_element(columnDimensions_.begin(), columnDimensions_.end())) {
588598
updateMinDutyCyclesGlobal_();
589599
} else {
@@ -869,7 +879,8 @@ void SpatialPooler::inhibitColumnsLocal_(const vector<Real> &overlaps,
869879

870880

871881
if (wrapAround_) {
872-
for(auto neighbor: WrappingNeighborhood(column, inhibitionRadius_,columnDimensions_)) {
882+
for(auto neighbor: WrappingNeighborhood(column, inhibitionRadius_,columnDimensions_)) { //TODO if we don't change inh radius (changes only every isUpdateRound()),
883+
// then these values can be cached -> faster local inh
873884
if (neighbor == column) {
874885
continue;
875886
}

src/htm/algorithms/SpatialPooler.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,10 @@ class SpatialPooler : public Serializable
197197
198198
*/
199199
virtual void
200-
initialize(const vector<UInt> inputDimensions, const vector<UInt> columnDimensions,
201-
UInt potentialRadius = 16u, Real potentialPct = 0.5f,
200+
initialize(const vector<UInt>& inputDimensions,
201+
const vector<UInt>& columnDimensions,
202+
UInt potentialRadius = 16u,
203+
Real potentialPct = 0.5f,
202204
bool globalInhibition = true,
203205
Real localAreaDensity = 0.05f,
204206
UInt stimulusThreshold = 0u,

0 commit comments

Comments
 (0)