Changed the reduced_decision_function_trainer2 object so that it performs a final

optimization of the weights before it finishes.  This ensures that we always
end up with the best weights for the support vectors we obtain after the
conjugate gradient optimization step.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%403069
This commit is contained in:
Davis King 2009-05-28 01:19:06 +00:00
parent 8122c10c72
commit 6d432586ed
1 changed files with 21 additions and 1 deletions

View File

@ -552,7 +552,27 @@ namespace dlib
// out_vectors matrices
obj.vector_to_state(opt_starting_point);
decision_function<kernel_type> new_df(beta,
// Do a final reoptimization of beta just to make sure it is optimal given the new
// set of support vectors.
for (long r = 0; r < K_inv.nr(); ++r)
{
for (long c = 0; c < K_inv.nc(); ++c)
{
K_inv(r,c) = kernel(out_vectors(r), out_vectors(c));
}
}
K_inv = pinv(K_inv);
for (long r = 0; r < K.nr(); ++r)
{
for (long c = 0; c < K.nc(); ++c)
{
K(r,c) = kernel(out_vectors(r), dec_funct.support_vectors(c));
}
}
decision_function<kernel_type> new_df(K_inv*K*dec_funct.alpha,
0,
kernel,
out_vectors);