Commit 31078ade authored by Csaba Kertesz's avatar Csaba Kertesz

Add maximal iterations option for relevance vector machine trainer

parent 2ba3c4d4
......@@ -147,8 +147,21 @@ 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 (
......@@ -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;
......
......@@ -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
......
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