-
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
SP: add equals operator== #7
Conversation
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.
still work in progress;
- need to decide how to implement the
==
- some options for cleanup/simplifying the tests
sp.getBoostFactors(boostFactors2); | ||
ASSERT_TRUE(check_vector_eq(boostFactors1, boostFactors2, numColumns)); | ||
delete[] boostFactors1; | ||
delete[] boostFactors2; |
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.
This seems like some optimization. Q: keep the delete[] (saves memory), or remove it (saves cycles, as the local memory is unallocated anyway at the end of the function/scope)
sp2.getSynPermTrimThreshold())); | ||
cout << "check: " << sp1.getSynPermActiveInc() << " " << | ||
sp2.getSynPermActiveInc() << endl; | ||
ASSERT_TRUE(almost_eq(sp1.getSynPermActiveInc(), |
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.
TODO: many uses of almost_eq()
can be replaced with gtest native EXCEPT_NEAR(a, b, diff);
and the function can be removed from SPTest class.
https://github.com/google/googletest/blob/master/googletest/docs/AdvancedGuide.md
Although, for the comparisons we need a boolean, not an assert; so we'd have to keep the function?
We'll just implement the small almost_eq method ; see "twice" in the example
numenta#1384 (comment)
auto boostFactors2 = new Real[numColumns]; | ||
sp1.getBoostFactors(boostFactors1); | ||
sp2.getBoostFactors(boostFactors2); | ||
ASSERT_TRUE(check_vector_eq(boostFactors1, boostFactors2, numColumns)); |
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.
Another function is check_vector_eq();
used in two scenarios:
- comparing
array[]
withvector<>
. this could be avoided ei byvector.data()
- for 2 vectors of Real, it calls
almost_eq
element-wise; I'm not sure if that can be done implicitly without the need for such function?
check_vector_eq
should be implemented as std::equal()
with the "twice" example:
http://www.tenouk.com/cpluscodesnippet/cplusstlvectoralgorithmequal.html
auto potential2 = new UInt[numInputs]; | ||
sp1.getPotential(i, potential1); | ||
sp2.getPotential(i, potential2); | ||
ASSERT_TRUE(check_vector_eq(potential1, potential2, numInputs)); |
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.
This is the case where check is within a for loop, so we'll have to create a variable that covers the whole loop:
bool allPotentialsEq = true;
for (..)
allPotentialsEq == allPotEq && check_vector_eq(..)
don't know if this is the place to mention this or not. I think the only way to do this right is to add a virtual operator==() in RegionImpl such that it will force all implementations to implement it. |
or remove it from the Region.
but I think this sounds reasonable, a RegionImpl would compare some of its settings, and then defer to sp/tm/...== |
Since this is not part of my current PR I will defer that one for things to
do.
For now we must remember that comparing two Network or Region objects in a
test, will probably not be very accurate.
…On Sat, Aug 18, 2018 at 5:56 PM breznak ***@***.***> wrote:
or remove it from the Region.
think the only way to do this right is to add a virtual operator==() in
RegionImpl such that it will force all implementations to implement it.
but I think this sounds reasonable, a RegionImpl would compare some of its
settings, and then defer to sp/tm/...==
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#7 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFBa_xtYckdCFSuYJLQwuYpr2jBDIUUoks5uSLehgaJpZM4RkVos>
.
|
Replaced by #133 |
Aims to implement
equals
for two SpatialPooler instances for more convenient comparisons & tests.Fixes: numenta#1383
Used for numenta#1380
Moved from numenta#1384