-
Notifications
You must be signed in to change notification settings - Fork 74
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
Fix SP initialize vs constructor differences #5
base: master
Are you sure you want to change the base?
Conversation
SP behaves differently when constructor vs setters are used to set the same parameters!
this sets the num active columns, but also has to disable mutex localAreaDensity, according to the API it's done by = -1; but the setter wrongly used =0; fixed
also causes difference
this fixes the issue with different SP states when constructor/setter is used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR with SP constructor fix + tests.
1 additional question to resolve, please see below.
@@ -186,7 +186,7 @@ UInt SpatialPooler::getPotentialRadius() const | |||
|
|||
void SpatialPooler::setPotentialRadius(UInt potentialRadius) | |||
{ | |||
potentialRadius_ = potentialRadius; | |||
potentialRadius_ = std::min(potentialRadius, numInputs_); //crop to numInputs (input size) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this caused the difference, because constructor does implicitly crop to bounds, while setter didn't.
TODO: do implicitly, or throw NTA_ASSERT?
@@ -196,6 +196,7 @@ Real SpatialPooler::getPotentialPct() const | |||
|
|||
void SpatialPooler::setPotentialPct(Real potentialPct) | |||
{ | |||
NTA_ASSERT(potentialPct > 0 && potentialPct <= 1); //bounds check |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
turn assert to always check?
We should check the public API and if it's public, always check. Other hand, performance impact.
@@ -219,7 +220,7 @@ void SpatialPooler::setNumActiveColumnsPerInhArea( | |||
{ | |||
NTA_ASSERT(numActiveColumnsPerInhArea > 0); | |||
numActiveColumnsPerInhArea_ = numActiveColumnsPerInhArea; | |||
localAreaDensity_ = 0; | |||
localAreaDensity_ = -1; //disabling |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixes the incompatibility with API documentation
@dkeeney please have a look, small PR, fixes a discrepancy in the API. Pls give your thoughts on the question: crop vs assert. |
Test configs need to be updated! |
Connections fix bindings py change
SP behaves differently when constructor vs setters are used to set the
same parameters!
Fixes SpatialPooler initialization with constructor vs initialize() results in different SP state numenta/nupic.core-legacy#1386
Moved from SP: add test for different constructor vs setter behavior numenta/nupic.core-legacy#1387