-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Spill trees #747
Spill trees #747
Changes from 1 commit
8adae19
634e271
8b2dc10
7aaf969
8d5994c
2e67697
c23f0b5
91334cb
061ee92
7bd4416
946eddf
c9f6cd3
e33a112
e1c01ca
723bec5
2af816a
5266096
a599bf8
b4d5a1d
9551cc6
9c1ef2a
498e74d
e95e3b4
0120357
5d68382
bff4eca
c86b32c
ce34be6
ea37f0d
f778e8e
a4ac0b2
9588a6d
4a66098
b9e23d4
a71b57c
54614ba
388941a
72274e7
fdc8e9c
8f32156
02d4a6d
e81731d
17d2c2f
d8b16a0
3b15fdf
fa81be4
9a8a9eb
f33a19d
d22e65a
69804c6
180fc11
c42e40b
7e5e054
d3ab34a
e06cfc8
722d211
89725f4
0757955
dce67ec
9215515
3e79d27
99de521
ac5f836
207c1d4
471bb24
f1253d3
f989164
02fb618
0267acb
70fbeab
b334674
e4ce9be
2bad753
b55534d
2698225
e4cf1fd
ecaf1bf
c5fe485
5795c74
ae84513
b1530ea
da35f94
8a5ec21
815391b
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 |
---|---|---|
|
@@ -34,13 +34,15 @@ BiSearchVisitor<SortPolicy>::BiSearchVisitor(const arma::mat& querySet, | |
arma::Mat<size_t>& neighbors, | ||
arma::mat& distances, | ||
const size_t leafSize, | ||
const double tau) : | ||
const double tau, | ||
const double rho) : | ||
querySet(querySet), | ||
k(k), | ||
neighbors(neighbors), | ||
distances(distances), | ||
leafSize(leafSize), | ||
tau(tau) | ||
tau(tau), | ||
rho(rho) | ||
{} | ||
|
||
//! Default Bichromatic neighbor search on the given NSType instance. | ||
|
@@ -84,7 +86,7 @@ void BiSearchVisitor<SortPolicy>::operator()(NSSpillType* ns) const | |
// For Dual Tree Search on SpillTrees, the queryTree must be built with | ||
// non overlapping (tau = 0). | ||
typename NSSpillType::Tree queryTree(std::move(querySet), 0 /* tau*/, | ||
leafSize); | ||
leafSize, rho); | ||
ns->Search(&queryTree, k, neighbors, distances); | ||
} | ||
else | ||
|
@@ -126,10 +128,12 @@ void BiSearchVisitor<SortPolicy>::SearchLeaf(NSType* ns) const | |
template<typename SortPolicy> | ||
TrainVisitor<SortPolicy>::TrainVisitor(arma::mat&& referenceSet, | ||
const size_t leafSize, | ||
const double tau) : | ||
const double tau, | ||
const double rho) : | ||
referenceSet(std::move(referenceSet)), | ||
leafSize(leafSize), | ||
tau(tau) | ||
tau(tau), | ||
rho(rho) | ||
{} | ||
|
||
//! Default Train on the given NSType instance. | ||
|
@@ -173,7 +177,7 @@ void TrainVisitor<SortPolicy>::operator ()(NSSpillType* ns) const | |
else | ||
{ | ||
typename NSSpillType::Tree* tree = new typename NSSpillType::Tree( | ||
std::move(referenceSet), tau, leafSize); | ||
std::move(referenceSet), tau, leafSize, rho); | ||
ns->Train(tree); | ||
// Give the model ownership of the tree. | ||
ns->neighborSearch.treeOwner = true; | ||
|
@@ -257,6 +261,7 @@ NSModel<SortPolicy>::NSModel(TreeTypes treeType, bool randomBasis) : | |
treeType(treeType), | ||
leafSize(20), | ||
tau(0), | ||
rho(0.7), | ||
randomBasis(randomBasis) | ||
{ | ||
// Nothing to do. | ||
|
@@ -307,6 +312,7 @@ void NSModel<SortPolicy>::Serialize(Archive& ar, | |
ar & data::CreateNVP(treeType, "treeType"); | ||
ar & data::CreateNVP(leafSize, "leafSize"); | ||
ar & data::CreateNVP(tau, "tau"); | ||
ar & data::CreateNVP(rho, "rho"); | ||
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 hate to always be talking about reverse compatibility, but this is reverse-incompatible, since tau, rho, and leafSize aren't part of the previous saved models. So the thing to do is to uncomment the You'll need to then set the serialization version. For
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 agree. Done in: 2698225 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. Looks good. I noticed that the previous revision did not serialize |
||
ar & data::CreateNVP(randomBasis, "randomBasis"); | ||
ar & data::CreateNVP(q, "q"); | ||
|
||
|
@@ -454,11 +460,11 @@ void NSModel<SortPolicy>::BuildModel(arma::mat&& referenceSet, | |
epsilon); | ||
break; | ||
case SPILL_TREE: | ||
nSearch = new NSSpillType(naive, singleMode, tau, epsilon); | ||
nSearch = new NSSpillType(naive, singleMode, tau, leafSize, rho, epsilon); | ||
break; | ||
} | ||
|
||
TrainVisitor<SortPolicy> tn(std::move(referenceSet), leafSize, tau); | ||
TrainVisitor<SortPolicy> tn(std::move(referenceSet), leafSize, tau, rho); | ||
boost::apply_visitor(tn, nSearch); | ||
|
||
if (!naive) | ||
|
@@ -491,7 +497,7 @@ void NSModel<SortPolicy>::Search(arma::mat&& querySet, | |
<< std::endl; | ||
|
||
BiSearchVisitor<SortPolicy> search(querySet, k, neighbors, distances, | ||
leafSize, tau); | ||
leafSize, tau, rho); | ||
boost::apply_visitor(search, nSearch); | ||
} | ||
|
||
|
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.
To emphasize where these are valid, I might consider writing
only valid for spill trees
instead of justfor spill trees
.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.
I agree. Done in: 99de521