"tools/git@developer.sourcefind.cn:OpenDAS/dlib.git" did not exist on "41a87e5926935c2328e9057a683c6ba6f9214cc9"
Commit 22d718b6 authored by Davis King's avatar Davis King
Browse files

Added some extra checks in the stopping conditions to avoid

getting stuck while training an rvm.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402461
parent 3a2ffaa7
...@@ -149,8 +149,8 @@ namespace dlib ...@@ -149,8 +149,8 @@ namespace dlib
!*/ !*/
matrix<long,0,1,mem_manager_type> active_bases(x.nr()); matrix<long,0,1,mem_manager_type> active_bases(x.nr());
scalar_matrix_type phi(x.nr(),1); scalar_matrix_type phi(x.nr(),1);
scalar_vector_type alpha(1); scalar_vector_type alpha(1), prev_alpha;
scalar_vector_type weights(1); scalar_vector_type weights(1), prev_weights;
scalar_vector_type tempv, K_col; scalar_vector_type tempv, K_col;
...@@ -244,6 +244,14 @@ namespace dlib ...@@ -244,6 +244,14 @@ namespace dlib
// check if we should do a full search for the best alpha to optimize // check if we should do a full search for the best alpha to optimize
if (ticker == rounds_of_narrow_search) if (ticker == rounds_of_narrow_search)
{ {
// if the current alpha and weights are equal to what they were
// at the last time we were about to start a wide search then
// we are done.
if (equal(prev_alpha, alpha, eps) && equal(prev_weights, weights, eps))
break;
prev_alpha = alpha;
prev_weights = weights;
search_all_alphas = true; search_all_alphas = true;
ticker = 0; ticker = 0;
} }
...@@ -279,6 +287,13 @@ namespace dlib ...@@ -279,6 +287,13 @@ namespace dlib
const long selected_idx = find_next_best_alpha_to_update(S,Q,alpha,active_bases, search_all_alphas); const long selected_idx = find_next_best_alpha_to_update(S,Q,alpha,active_bases, search_all_alphas);
// if we just did a search of all the alphas and it still put is back
// into the current active set then we are done.
if (search_all_alphas == true && active_bases(selected_idx) != -1)
{
break;
}
// if find_next_best_alpha_to_update didn't find any good alpha to update // if find_next_best_alpha_to_update didn't find any good alpha to update
if (selected_idx == -1) if (selected_idx == -1)
...@@ -693,8 +708,8 @@ namespace dlib ...@@ -693,8 +708,8 @@ namespace dlib
!*/ !*/
matrix<long,0,1,mem_manager_type> active_bases(x.nr()); matrix<long,0,1,mem_manager_type> active_bases(x.nr());
scalar_matrix_type phi(x.nr(),1); scalar_matrix_type phi(x.nr(),1);
scalar_vector_type alpha(1); scalar_vector_type alpha(1), prev_alpha;
scalar_vector_type weights(1); scalar_vector_type weights(1), prev_weights;
scalar_vector_type tempv, K_col; scalar_vector_type tempv, K_col;
scalar_type var = variance(t)*0.1; scalar_type var = variance(t)*0.1;
...@@ -739,6 +754,14 @@ namespace dlib ...@@ -739,6 +754,14 @@ namespace dlib
// check if we should do a full search for the best alpha to optimize // check if we should do a full search for the best alpha to optimize
if (ticker == rounds_of_narrow_search) if (ticker == rounds_of_narrow_search)
{ {
// if the current alpha and weights are equal to what they were
// at the last time we were about to start a wide search then
// we are done.
if (equal(prev_alpha, alpha, eps) && equal(prev_weights, weights, eps))
break;
prev_alpha = alpha;
prev_weights = weights;
search_all_alphas = true; search_all_alphas = true;
ticker = 0; ticker = 0;
} }
...@@ -774,6 +797,12 @@ namespace dlib ...@@ -774,6 +797,12 @@ namespace dlib
const long selected_idx = find_next_best_alpha_to_update(S,Q,alpha,active_bases, search_all_alphas); const long selected_idx = find_next_best_alpha_to_update(S,Q,alpha,active_bases, search_all_alphas);
// if we just did a search of all the alphas and it still put is back
// into the current active set then we are done.
if (search_all_alphas == true && active_bases(selected_idx) != -1)
{
break;
}
// if find_next_best_alpha_to_update didn't find any good alpha to update // if find_next_best_alpha_to_update didn't find any good alpha to update
if (selected_idx == -1) if (selected_idx == -1)
......
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