-
Notifications
You must be signed in to change notification settings - Fork 75
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
Dropout WIP #535
base: master
Are you sure you want to change the base?
Dropout WIP #535
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -308,6 +308,22 @@ namespace htm { | |
} | ||
|
||
|
||
void SparseDistributedRepresentation::addNoise2(const Real probability, Random& rng) { | ||
NTA_ASSERT( probability >= 0.0f and probability <= 1.0f ); | ||
const ElemSparse numFlip = static_cast<ElemSparse>(size * probability); | ||
if (numFlip == 0) return; | ||
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. I'm trying to write an effective implementation, but this has problem with p << size. Should we bother with such cases? return/assert? |
||
|
||
// instead of applying probability `p` `n` (=size) times to each bit, | ||
// flip `p*n` random bits. | ||
getDense(); //create dense_ array | ||
for (ElemSparse i=0; i < numFlip; i++) { | ||
const ElemSparse toggle = static_cast<ElemSparse>(rng.getUInt32(size)); | ||
dense_[toggle] ^= true; //XOR, flip | ||
} | ||
setDenseInplace(); | ||
} | ||
|
||
|
||
void SparseDistributedRepresentation::addNoise(Real fractionNoise) { | ||
Random rng( 0 ); | ||
addNoise( fractionNoise, rng ); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -471,10 +471,16 @@ class SparseDistributedRepresentation : public Serializable | |
* @param rng The random number generator to draw from. If not given, this | ||
* makes one using the magic seed 0. | ||
*/ | ||
void addNoise(Real fractionNoise); | ||
void addNoise(Real fractionNoise); //TODO the name is confusing, rename to shuffle ? | ||
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. is it OK to rename this to shuffle() and have addNoise for the new fn? @ctrl-z-9000-times 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. I looked at your new 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. that would be indeed wrong. What I intended:
So the sparsity would remain the same (actially grow, because we have much more off bits, so flipping on would be more probable). But it should remain the x% (2%) + 0.001% |
||
|
||
void addNoise(Real fractionNoise, Random &rng); | ||
|
||
/** | ||
* actual add noise :) | ||
* TODO doc | ||
*/ | ||
void addNoise2(const Real probability, Random& rng); | ||
|
||
/** | ||
* Modify the SDR by setting a fraction of the bits to zero. | ||
* | ||
|
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.
proof of concept dropout applied to input (as noise) and output (as killCells).