merged changes and updated abstract file.

This commit is contained in:
Davis King 2014-04-22 20:13:47 -04:00
commit 2821926236
3 changed files with 38 additions and 2 deletions

View File

@ -147,10 +147,23 @@ namespace dlib
typedef decision_function<kernel_type> trained_function_type; typedef decision_function<kernel_type> trained_function_type;
rvm_trainer ( rvm_trainer (
) : eps(0.001) ) : eps(0.001), max_iterations(2000)
{ {
} }
void set_max_iterations (
unsigned long max_iterations_
)
{
max_iterations = max_iterations_;
}
unsigned long get_max_iterations (
) const
{
return max_iterations;
}
void set_epsilon ( void set_epsilon (
scalar_type eps_ scalar_type eps_
) )
@ -288,9 +301,11 @@ namespace dlib
bool search_all_alphas = false; bool search_all_alphas = false;
unsigned long ticker = 0; unsigned long ticker = 0;
const unsigned long rounds_of_narrow_search = 100; const unsigned long rounds_of_narrow_search = 100;
unsigned long iterations = 0;
while (true) while (iterations != max_iterations)
{ {
iterations++;
if (recompute_beta) if (recompute_beta)
{ {
// calculate the current t_estimate. (this is the predicted t value for each sample according to the // calculate the current t_estimate. (this is the predicted t value for each sample according to the
@ -572,6 +587,7 @@ namespace dlib
// private member variables // private member variables
kernel_type kernel; kernel_type kernel;
scalar_type eps; scalar_type eps;
unsigned long max_iterations;
const static scalar_type tau; const static scalar_type tau;

View File

@ -50,6 +50,7 @@ namespace dlib
- This object is properly initialized and ready to be used - This object is properly initialized and ready to be used
to train a relevance vector machine. to train a relevance vector machine.
- #get_epsilon() == 0.001 - #get_epsilon() == 0.001
- #get_max_iterations() == 2000
!*/ !*/
void set_epsilon ( void set_epsilon (
@ -86,6 +87,22 @@ namespace dlib
- returns a copy of the kernel function in use by this object - returns a copy of the kernel function in use by this object
!*/ !*/
unsigned long get_max_iterations (
) const;
/*!
ensures
- returns the maximum number of iterations the RVM optimizer is allowed to
run before it is required to stop and return a result.
!*/
void set_max_iterations (
unsigned long max_iter
);
/*!
ensures
- #get_max_iterations() == max_iter
!*/
template < template <
typename in_sample_vector_type, typename in_sample_vector_type,
typename in_scalar_vector_type typename in_scalar_vector_type

View File

@ -103,6 +103,9 @@ int main()
// stopping epsilon bigger. However, this might make the outputs less // stopping epsilon bigger. However, this might make the outputs less
// reliable. But sometimes it works out well. 0.001 is the default. // reliable. But sometimes it works out well. 0.001 is the default.
trainer.set_epsilon(0.001); trainer.set_epsilon(0.001);
// You can also set an explicit limit on the number of iterations used by the numeric
// solver. The default is 2000.
trainer.set_max_iterations(2000);
// Now we loop over some different gamma values to see how good they are. Note // Now we loop over some different gamma values to see how good they are. Note
// that this is a very simple way to try out a few possible parameter choices. You // that this is a very simple way to try out a few possible parameter choices. You