Commit 1372472d authored by Davis King's avatar Davis King

Added an optional hard limit on the number of iterations in the

structural SVM solver.
parent 65d838e6
......@@ -345,6 +345,7 @@ namespace dlib
svm_struct_controller_node (
) :
eps(0.001),
max_iterations(10000),
cache_based_eps(std::numeric_limits<double>::infinity()),
verbose(false),
C(1)
......@@ -389,6 +390,16 @@ namespace dlib
double get_epsilon (
) const { return eps; }
unsigned long get_max_iterations (
) const { return max_iterations; }
void set_max_iterations (
unsigned long max_iter
)
{
max_iterations = max_iter;
}
void be_verbose (
)
{
......@@ -515,6 +526,7 @@ namespace dlib
problem_type<matrix_type> problem(nodes);
problem.set_cache_based_epsilon(cache_based_eps);
problem.set_epsilon(eps);
problem.set_max_iterations(max_iterations);
if (verbose)
problem.be_verbose();
problem.set_c(C);
......@@ -674,6 +686,7 @@ namespace dlib
std::vector<network_address> nodes;
double eps;
unsigned long max_iterations;
double cache_based_eps;
bool verbose;
double C;
......
......@@ -64,6 +64,7 @@ namespace dlib
INITIAL VALUE
- get_num_processing_nodes() == 0
- get_epsilon() == 0.001
- get_max_iterations() == 10000
- get_c() == 1
- This object will not be verbose
......@@ -182,6 +183,22 @@ namespace dlib
- #get_cache_based_epsilon() == eps
!*/
void set_max_iterations (
unsigned long max_iter
);
/*!
ensures
- #get_max_iterations() == max_iter
!*/
unsigned long get_max_iterations (
);
/*!
ensures
- returns the maximum number of iterations the SVM optimizer is allowed to
run before it is required to stop and return a result.
!*/
void add_nuclear_norm_regularizer (
long first_dimension,
long rows,
......
......@@ -239,6 +239,7 @@ namespace dlib
CONVENTION
- C == get_c()
- eps == get_epsilon()
- max_iterations == get_max_iterations()
- if (skip_cache) then
- we won't use the oracle cache when we need to evaluate the separation
oracle. Instead, we will directly call the user supplied separation_oracle().
......@@ -259,6 +260,7 @@ namespace dlib
) :
saved_current_risk_gap(0),
eps(0.001),
max_iterations(10000),
verbose(false),
skip_cache(true),
count_below_eps(0),
......@@ -308,6 +310,16 @@ namespace dlib
const scalar_type get_epsilon (
) const { return eps; }
unsigned long get_max_iterations (
) const { return max_iterations; }
void set_max_iterations (
unsigned long max_iter
)
{
max_iterations = max_iter;
}
void set_max_cache_size (
unsigned long max_size
)
......@@ -445,6 +457,9 @@ namespace dlib
cout << endl;
}
if (num_iterations >= max_iterations)
return true;
saved_current_risk_gap = current_risk_gap;
if (converged)
......@@ -611,6 +626,7 @@ namespace dlib
mutable scalar_type saved_current_risk_gap;
mutable matrix_type psi_true;
scalar_type eps;
unsigned long max_iterations;
mutable bool verbose;
......
......@@ -29,6 +29,7 @@ namespace dlib
INITIAL VALUE
- get_epsilon() == 0.001
- get_max_iterations() == 10000
- get_max_cache_size() == 5
- get_c() == 1
- get_cache_based_epsilon() == std::numeric_limits<scalar_type>::infinity()
......@@ -161,6 +162,22 @@ namespace dlib
- #get_cache_based_epsilon() == eps
!*/
void set_max_iterations (
unsigned long max_iter
);
/*!
ensures
- #get_max_iterations() == max_iter
!*/
unsigned long get_max_iterations (
);
/*!
ensures
- returns the maximum number of iterations the SVM optimizer is allowed to
run before it is required to stop and return a result.
!*/
void set_max_cache_size (
unsigned long max_size
);
......
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