Commit d1a3dcd3 authored by Davis King's avatar Davis King

Optimized the krr_trainer a bit. It's now twice as fast as it was before. I

also increased the default number of lambdas in the search list.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%403768
parent 9114f861
......@@ -36,7 +36,7 @@ namespace dlib
ekm_stale(true)
{
// default lambda search list
lams = logspace(-9, 2, 40);
lams = logspace(-9, 2, 50);
}
void be_verbose (
......@@ -349,6 +349,15 @@ namespace dlib
const general_matrix_type V = eig.get_pseudo_v();
const column_matrix_type D = eig.get_real_eigenvalues();
// We can save some work by pre-multiplying the proj_x vectors by trans(V)
// and saving the result so we don't have to recompute it over and over later.
matrix<column_matrix_type,0,1,mem_manager_type > Vx;
if (lambda == 0 || output_looe)
{
Vx.set_size(proj_x.size());
for (long i = 0; i < proj_x.size(); ++i)
Vx(i) = squared(trans(V)*proj_x(i));
}
the_lambda = lambda;
......@@ -372,7 +381,8 @@ namespace dlib
scalar_type looe = 0;
for (long i = 0; i < proj_x.size(); ++i)
{
const scalar_type val = trans(proj_x(i))*G*proj_x(i);
// perform equivalent of: val = trans(proj_x(i))*G*proj_x(i);
const scalar_type val = dot(tempv, Vx(i));
const scalar_type temp = (1 - val);
scalar_type loov;
if (temp != 0)
......@@ -419,7 +429,8 @@ namespace dlib
best_looe = 0;
for (long i = 0; i < proj_x.size(); ++i)
{
const scalar_type val = trans(proj_x(i))*G*proj_x(i);
// perform equivalent of: val = trans(proj_x(i))*G*proj_x(i);
const scalar_type val = dot(tempv, Vx(i));
const scalar_type temp = (1 - val);
scalar_type loov;
if (temp != 0)
......
......@@ -24,7 +24,7 @@ namespace dlib
- basis_loaded() == false
- get_max_basis_size() == 400
- will_use_regression_loss_for_loo_cv() == true
- get_search_lambdas() == logspace(-9, 2, 40)
- get_search_lambdas() == logspace(-9, 2, 50)
- this object will not be verbose unless be_verbose() is called
WHAT THIS OBJECT REPRESENTS
......
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