Add maximal iterations option for relevance vector machine trainer

This commit is contained in:
Csaba Kertesz 2014-03-16 12:19:19 +01:00
parent 2ba3c4d47c
commit 31078adee9
2 changed files with 23 additions and 2 deletions

View File

@ -147,10 +147,23 @@ namespace dlib
typedef decision_function<kernel_type> trained_function_type;
rvm_trainer (
) : eps(0.001)
) : eps(0.001), max_iterations(2000)
{
}
void set_max_iterations (
int max_iterations_
)
{
max_iterations = max_iterations_;
}
int get_max_iterations (
) const
{
return max_iterations;
}
void set_epsilon (
scalar_type eps_
)
@ -288,9 +301,11 @@ namespace dlib
bool search_all_alphas = false;
unsigned long ticker = 0;
const unsigned long rounds_of_narrow_search = 100;
int iterations = 0;
while (true)
while (iterations != max_iterations)
{
iterations++;
if (recompute_beta)
{
// 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
kernel_type kernel;
scalar_type eps;
int max_iterations;
const static scalar_type tau;

View File

@ -104,6 +104,11 @@ int main()
// reliable. But sometimes it works out well. 0.001 is the default.
trainer.set_epsilon(0.001);
// The relevance vector machine with radial basis function tends to learn too long and
// sometimes it is stuck forever. A default iterations limit is 2000, but it can be disabled by
// setting equal or less than zero.
trainer.set_max_iterations(0);
// 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
// should look at the model_selection_ex.cpp program for examples of more sophisticated