Skip to content
This repository has been archived by the owner on Sep 1, 2023. It is now read-only.

Commit

Permalink
working SP test for unstable params
Browse files Browse the repository at this point in the history
the unstable combination of constructor parameters can cause SP
output to be different on the same input, which is clearly wrong!
  • Loading branch information
breznak committed Jan 11, 2018
1 parent eba72d0 commit 30f9227
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions src/test/unit/algorithms/SpatialPoolerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2223,21 +2223,30 @@ namespace {
}


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

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());
/** this test exposes bug where c++ SP (wrongly) produces
different output for the same input.
XXX sensitive - marks (empirically!) discovered set of parameter
that produce the err behavior; changing any of the XXX params
may cause the SP to behave "normally"
*/
SpatialPooler sp{std::vector<UInt>{10} /* input*/, std::vector<UInt>{2048}/* SP output cols XXX sensitive*/,
/*pot radius*/ 20, //each col sees
/*pot pct*/ 0.5, //XXX sensitive
/*global inhibition*/ false, //XXX sensitive
/*Real localAreaDensity=*/0.02, //2% active cols
/*UInt numActiveColumnsPerInhArea=*/0, //mutex with above ^^ //XXX sensitive
};

vector<UInt> input = { 1, 1, 0, 0, 1, 1, 0, 0, 1, 1};
vector<UInt> out1(sp.getNumColumns(), 0);
vector<UInt> out2(sp.getNumColumns(), 0);
sp.compute(input.data(), true, out1.data());
sp.compute(input.data(), true, out2.data());
EXPECT_EQ(out1, out2);
}
}


TEST(SpatialPoolerTest, testSaveLoad)
{
Expand Down

0 comments on commit 30f9227

Please sign in to comment.