mirror of
https://github.com/davisking/dlib.git
synced 2024-11-01 10:14:53 +08:00
Add maximal iterations option for relevance vector machine trainer
This commit is contained in:
parent
2ba3c4d47c
commit
31078adee9
@ -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 (
|
||||||
|
int max_iterations_
|
||||||
|
)
|
||||||
|
{
|
||||||
|
max_iterations = max_iterations_;
|
||||||
|
}
|
||||||
|
|
||||||
|
int 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;
|
||||||
|
int 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;
|
||||||
|
int max_iterations;
|
||||||
|
|
||||||
const static scalar_type tau;
|
const static scalar_type tau;
|
||||||
|
|
||||||
|
@ -104,6 +104,11 @@ int main()
|
|||||||
// 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);
|
||||||
|
|
||||||
|
// 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
|
// 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
|
||||||
// should look at the model_selection_ex.cpp program for examples of more sophisticated
|
// should look at the model_selection_ex.cpp program for examples of more sophisticated
|
||||||
|
Loading…
Reference in New Issue
Block a user