[mlpack] Det Bug ticket #334
Aakash Chaudhary
aakash2200 at gmail.com
Fri Mar 7 13:05:21 EST 2014
the svn diff:
Index: src/mlpack/methods/det/dt_utils.cpp
===================================================================
--- src/mlpack/methods/det/dt_utils.cpp (revision 16347)
+++ src/mlpack/methods/det/dt_utils.cpp (working copy)
@@ -215,7 +215,7 @@
// Sequentially prune with all the values of available alphas and
adding
// values for test values.
- for (size_t i = 0; i < prunedSequence.size() - 2; ++i)
+ for (size_t i = 0; i < ((prunedSequence.size() <= 1) ? 0 :
prunedSequence.size() - 2); ++i)
{
// Compute test values for this state of the tree.
double cvVal = 0.0;
@@ -242,7 +242,7 @@
cvVal += cvDTree->ComputeValue(testPoint);
}
- regularizationConstants[prunedSequence.size() - 2] += 2.0 * cvVal /
+ regularizationConstants[((prunedSequence.size() <= 1) ? 0 :
prunedSequence.size() - 2)] += 2.0 * cvVal /
(double) dataset.n_cols;
test.reset();
explanation
/*
the first change ( you gave that as hint even then i am explaining
)
the value of prunedSequence.size() - 2 becomes big when
prunedSequence.size() = 1 or 0 (the number of nodes)
which results into for loop execution nearly infinte times
resulting into segmentation fault
now about the second change the same thing is happening
assuming prunedSequence.size() = 1 or 0 [for other values it will work as
it used to be]
and you were saying that it might effect the output but it wont because
at line 255 there is a for loop
for (size_t i = 0; i < prunedSequence.size() - 1; ++i)
regularizationConstants[i] is used in this *for loop* and wont be used
after that
and that *for loop* wont be executed because it will fail condition i <
prunedSequence.size() - 1 (for loop condition)
and hence we don't have to be worried about what is stored in
regularizationConstants vector
it doesnt affect the outcome of program and also will not result into
segmentation fault
i know this might not be a good explanation but just tell me what i was not
able to explain and i will try to explain that part in a better way
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.cc.gatech.edu/pipermail/mlpack/attachments/20140307/6eb9f0df/attachment.html>
More information about the mlpack
mailing list