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

SP: add test for different constructor vs setter behavior #1387

Closed
Closed
Changes from 1 commit
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
28 changes: 28 additions & 0 deletions src/test/unit/algorithms/SpatialPoolerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2222,6 +2222,34 @@ namespace {
EXPECT_EQ(0, countNonzero(activeColumns));
}


TEST(SpatialPoolerTest, testDifferentConstructorVsSetterBehavior)
{
/** this test exposes wrong behavior, where SP created via constructor
behaves differently to a SP via setters (setXXX()), both with the same
params.
*/
SpatialPooler spConstruct{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
};

SpatialPooler sp{std::vector<UInt>{10} /* input*/, std::vector<UInt>{2048}/* SP output cols */};
sp.setPotentialRadius(20);
sp.setPotentialPct(0.5);
sp.setGlobalInhibition(false);
sp.setLocalAreaDensity(0.02); //2% active cols
sp.setNumActiveColumnsPerInhArea(0); //mutex with above ^^
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 suspect an issue in these 2 values, which are mutually exclusive. the Num Active Cols per Inh Area should never be zero



// EXPECT_EQ(spConstruct, sp); //FIXME how compare 2 SP
check_spatial_eq(spConstruct, sp);
}


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