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

Issue #1380: Add SP test checking results with no learning and 0 boos… #1381

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/test/unit/algorithms/SpatialPoolerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2222,6 +2222,23 @@ namespace {
EXPECT_EQ(0, countNonzero(activeColumns));
}


TEST(SpatialPoolerTest, testSameOutputForSameInputNoLearningNoBoosting)
{
const UInt inputSize = 10;
const UInt nColumns = 20;
SpatialPooler sp;
sp.initialize({inputSize}, {nColumns});
sp.setBoostStrength(0);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest some explanatory comment here:
"This test verifies possible issue where SP with 0-boosting and learning disabled produces different (random) output, compared to the python SP. "
and add
bool learning = False;


vector<UInt> input = { 1, 1, 0, 0, 1, 1, 0, 0, 1, 1 };
vector<UInt> out1(nColumns, 0);
vector<UInt> out2(nColumns, 0);
sp.compute(input.data(), false, out1.data());
sp.compute(input.data(), false, out2.data());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • we'll definitely need more then one iteration, the issue seems to manifest "after some time" (-> an overflow?); I'm suggesting to test on a sequence of random with a fixed seed
  • I'm not sure what @scottpurdy was thinking, I'd either compare two c++ SP instances, or better a c++ and py SP.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I take it back. Neither of that is needed, I can replicate the issue now and will post the test-case. Seems to be related to initial params (and initialization via constructor vs. sp.setXXX())

EXPECT_EQ(out1, out2);
}

TEST(SpatialPoolerTest, testSaveLoad)
{
const char* filename = "SpatialPoolerSerialization.tmp";
Expand Down