forked from numenta/nupic.core-legacy
-
Notifications
You must be signed in to change notification settings - Fork 74
SDR replaces VectorHelpers #320
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
Open
breznak
wants to merge
54
commits into
master
Choose a base branch
from
sdr_cleanup
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 51 commits
Commits
Show all changes
54 commits
Select commit
Hold shift + click to select a range
e2fa54e
SDR: make sdr_dense_t element UInt, from char
breznak 70cdb1a
SpatialPooler: use SDR for conversion from sparse/dense
breznak f651b42
SDR: make set*Inplace() public
breznak 858d1f3
SDRProxy fix UInt in dense
breznak 3391f78
Hotgym: use SDR instead of VectorHelpers
breznak 4d793ab
SDR: equals uses getSparse internally
breznak c2bcb04
fix pybindings for SDR getDense change to vector<UInt>
breznak 6d68136
SDR: update unit test
breznak bdb7ffd
Hotgym: use compute(SDR) calls
breznak 83d0e9c
SDR: TMP rever to Byte for dense()
breznak 9cfd73d
TM: add compute(SDR, learn) without extra inputs wrapper
breznak 6371aa2
SpatialPooler: use SDR, sparse initMapPotentials
breznak eb016bc
Revert "SDR: make set*Inplace() public"
breznak 1f430b2
Hotgym fix SDR use
breznak 11a6190
Hotgym code fix
breznak d4cf24d
SDR: move to namespace nupic::sdr, allow copy-constructor
breznak dc7fb3c
Revert "SDR: move to namespace nupic::sdr, allow copy-constructor"
breznak 436c600
Merge branch 'master_community' into sdr_cleanup
breznak 96302f9
SP: initMapPotential takes output SDR as its parameter
breznak e303d36
fix py binding
breznak a76cd0e
SP: fix test for initMapPotential
breznak 53dd7ac
SDR: again use dense for equals
breznak 4cf4c05
SDR test fixes
breznak 6c2106d
VectorHelpers: remove sparseToBinary, binaryToSparse
breznak 0469db8
BacktrackingTM Region: use SDR instead of VectorHelpers
breznak b331253
TMRegion tests: use SDR instead of VectorHelpers
breznak 6818ef0
BackTM Test: use SDR instead of VectorHelpers::binaryToSparse
breznak 24350fe
Merge branch 'master' into sdr_cleanup
breznak 182a7af
rm unused variable
breznak 355f73f
SDR fix tests
breznak 7e7bd2a
SDR setSparse add debug check that input vector is not cleared
breznak 9866a36
Revert "SDR setSparse add debug check that input vector is not cleared"
breznak d12bff8
SDR: fix test
breznak e30add5
Merge branch 'master_community' into sdr_cleanup
breznak bed3bdf
improved asserts
breznak 9a9575d
Merge branch 'master_community' into sdr_cleanup
breznak f2d1a0d
merge fixes
breznak 2b1cf93
Merge branch 'master_community' into sdr_cleanup
breznak 2823d4e
Merge branch 'master_community' into sdr_cleanup
breznak 3ca10e4
Connections: adaptSegment small cleanup
breznak a9912f3
Merge branch 'master_community' into sdr_cleanup
breznak ffeb5a6
Merge branch 'master_community' into sdr_cleanup
breznak d37daf9
post merge conflicts
breznak 954013e
remove whitespace changes
breznak 4a850b9
Merge branch 'master_community' into sdr_cleanup
breznak 0243edc
Merge branch 'master_community' into sdr_cleanup
breznak a324d30
Merge branch 'master_community' into sdr_cleanup
breznak a738702
Merge branch 'master_community' into sdr_cleanup
breznak 7643e34
Merge branch 'master_community' into sdr_cleanup
breznak cb1ce21
fix merge conflicts
breznak 3de7990
some review feedback
breznak 409c9d4
SDR Unit Tests: fixes & comments
ctrl-z-9000-times 2604dd0
fix sorted inputs for SDR
breznak a1d9a14
remove obsoleted VectorHelpers file
breznak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -450,18 +450,17 @@ void SpatialPooler::initialize( | |
inhibitionRadius_ = 0; | ||
|
||
connections_.initialize(numColumns_, synPermConnected_); | ||
for (Size i = 0; i < numColumns_; ++i) { | ||
connections_.createSegment( (CellIdx)i ); | ||
|
||
// Note: initMapPotential_ & initPermanence_ return dense arrays. | ||
vector<UInt> potential = initMapPotential_((UInt)i, wrapAround_); | ||
vector<Real> perm = initPermanence_(potential, initConnectedPct_); | ||
for(UInt presyn = 0; presyn < numInputs_; presyn++) { | ||
if( potential[presyn] ) | ||
connections_.createSynapse( (Segment)i, presyn, perm[presyn] ); | ||
for (Size column = 0; column < numColumns_; column++) { | ||
connections_.createSegment( static_cast<CellIdx>(column) ); | ||
|
||
SDR potential({numInputs_}); | ||
initMapPotential_(static_cast<UInt>(column), wrapAround_, potential); | ||
const vector<Real> perm = initPermanence_(potential, initConnectedPct_); | ||
for(const auto presyn : potential.getSparse()) { | ||
connections_.createSynapse( static_cast<Segment>(column), presyn, perm[presyn] ); | ||
} | ||
|
||
connections_.raisePermanencesToThreshold( (Segment)i, stimulusThreshold_ ); | ||
connections_.raisePermanencesToThreshold( static_cast<Segment>(column), stimulusThreshold_ ); | ||
} | ||
|
||
updateInhibitionRadius_(); | ||
|
@@ -505,6 +504,7 @@ void SpatialPooler::compute(const SDR &input, const bool learn, SDR &active) { | |
|
||
void SpatialPooler::boostOverlaps_(const vector<SynapseIdx> &overlaps, //TODO use Eigen sparse vector here | ||
vector<Real> &boosted) const { | ||
NTA_ASSERT(overlaps.size() == numColumns_); | ||
for (UInt i = 0; i < numColumns_; i++) { | ||
boosted[i] = overlaps[i] * boostFactors_[i]; | ||
} | ||
|
@@ -530,8 +530,10 @@ UInt SpatialPooler::initMapColumn_(UInt column) const { | |
} | ||
|
||
|
||
vector<UInt> SpatialPooler::initMapPotential_(UInt column, bool wrapAround) { | ||
NTA_ASSERT(column < numColumns_); | ||
void SpatialPooler::initMapPotential_(UInt column, bool wrapAround, SDR& potential) { | ||
NTA_CHECK(potential.size == numInputs_); | ||
NTA_CHECK(column < numColumns_); | ||
|
||
const UInt centerInput = initMapColumn_(column); | ||
|
||
vector<UInt> columnInputs; | ||
|
@@ -548,8 +550,7 @@ vector<UInt> SpatialPooler::initMapPotential_(UInt column, bool wrapAround) { | |
|
||
const UInt numPotential = (UInt)round(columnInputs.size() * potentialPct_); | ||
const auto selectedInputs = rng_.sample<UInt>(columnInputs, numPotential); | ||
const vector<UInt> potential = VectorHelpers::sparseToBinary<UInt>(selectedInputs, numInputs_); | ||
return potential; | ||
potential.setSparse(selectedInputs); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not sorted! This is the bug causing the Because the potential pool is not sorted, the initial Permanences are randomly generated differently than before. This also fails in debug mode where there is an |
||
} | ||
|
||
|
||
|
@@ -563,14 +564,9 @@ Real SpatialPooler::initPermNonConnected_() { | |
} | ||
|
||
|
||
vector<Real> SpatialPooler::initPermanence_(const vector<UInt> &potential, //TODO make potential sparse | ||
Real connectedPct) { | ||
const vector<Real> SpatialPooler::initPermanence_(const SDR &potential, const Real connectedPct) { | ||
vector<Real> perm(numInputs_, 0); | ||
for (UInt i = 0; i < numInputs_; i++) { | ||
if (potential[i] < 1) { | ||
continue; | ||
} | ||
|
||
for (const auto i : potential.getSparse()) { | ||
if (rng_.getReal64() <= connectedPct) { | ||
perm[i] = initPermConnected_(); | ||
} else { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.