Commit 39b3e759 authored by Davis King's avatar Davis King

Added a bit of code to remove basis vectors with zero weights from the output

of the reduced2() trainer adapter.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%403697
parent 022b9f71
......@@ -507,6 +507,20 @@ namespace dlib
// set of basis vectors.
beta = pinv(kernel_matrix(kern,out_vectors))*(kernel_matrix(kern,out_vectors,dec_funct.basis_vectors)*dec_funct.alpha);
// It is possible that some of the beta weights will be very close to zero. Lets remove
// the basis vectors with these essentially zero weights.
const scalar_type eps = max(abs(beta))*std::numeric_limits<scalar_type>::epsilon();
for (long i = 0; i < beta.size(); ++i)
{
// if beta(i) is zero
if (std::abs(beta(i)) < eps)
{
beta = remove_row(beta, i);
out_vectors = remove_row(out_vectors, i);
--i;
}
}
decision_function<kernel_type> new_df(beta,
0,
kern,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment