Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimizations to local inhibition #769

Merged
merged 9 commits into from Feb 20, 2020
13 changes: 12 additions & 1 deletion src/htm/algorithms/SpatialPooler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -866,16 +866,27 @@ void SpatialPooler::inhibitColumnsLocal_(const vector<Real> &overlaps,


if (wrapAround_) {
numNeighbors = 0; // In wrapAround, number of neighbors to be considered is solely a function of the inhibition radius,
// ... the number of dimensions, and of the size of each of those dimenion
UInt predN = 1;
const UInt diam = 2*inhibitionRadius_ + 1; //the inh radius can change, that's why we recompute here
for (const auto dim : columnDimensions_) {
predN *= std::min(diam, dim);
}
predN -= 1;
numNeighbors = predN;
const UInt numActive_wrap = static_cast<UInt>(0.5f + (density * (numNeighbors + 1)));

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

const Real difference = overlaps[neighbor] - overlaps[column];
if (difference > 0 || (difference == 0 && activeColumnsDense[neighbor])) {
numBigger++;
if (numBigger >= numActive_wrap) { break; }
}
}
} else {
Expand Down