Commit 07c43999 authored by Davis King's avatar Davis King

Added get_kernel() member functions to the reduced set trainers.

Also added missing comments to the spec.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402424
parent 8e8b04d9
...@@ -46,6 +46,12 @@ namespace dlib ...@@ -46,6 +46,12 @@ namespace dlib
); );
} }
const kernel_type& get_kernel (
) const
{
return trainer.get_kernel();
}
template < template <
typename in_sample_vector_type, typename in_sample_vector_type,
typename in_scalar_vector_type typename in_scalar_vector_type
...@@ -187,7 +193,7 @@ namespace dlib ...@@ -187,7 +193,7 @@ namespace dlib
COMPILE_TIME_ASSERT(is_matrix<sample_type>::value); COMPILE_TIME_ASSERT(is_matrix<sample_type>::value);
// make sure requires clause is not broken // make sure requires clause is not broken
DLIB_ASSERT(num_sv > 0, DLIB_ASSERT(num_sv > 0 && eps > 0,
"\t reduced_decision_function_trainer2()" "\t reduced_decision_function_trainer2()"
<< "\n\t you have given invalid arguments to this function" << "\n\t you have given invalid arguments to this function"
<< "\n\t num_sv: " << num_sv << "\n\t num_sv: " << num_sv
...@@ -195,6 +201,12 @@ namespace dlib ...@@ -195,6 +201,12 @@ namespace dlib
); );
} }
const kernel_type& get_kernel (
) const
{
return trainer.get_kernel();
}
template < template <
typename in_sample_vector_type, typename in_sample_vector_type,
typename in_scalar_vector_type typename in_scalar_vector_type
...@@ -576,7 +588,7 @@ namespace dlib ...@@ -576,7 +588,7 @@ namespace dlib
COMPILE_TIME_ASSERT(is_matrix<typename trainer_type::sample_type>::value); COMPILE_TIME_ASSERT(is_matrix<typename trainer_type::sample_type>::value);
// make sure requires clause is not broken // make sure requires clause is not broken
DLIB_ASSERT(num_sv > 0, DLIB_ASSERT(num_sv > 0 && eps > 0,
"\tconst reduced_decision_function_trainer2 reduced2()" "\tconst reduced_decision_function_trainer2 reduced2()"
<< "\n\t you have given invalid arguments to this function" << "\n\t you have given invalid arguments to this function"
<< "\n\t num_sv: " << num_sv << "\n\t num_sv: " << num_sv
......
...@@ -54,6 +54,14 @@ namespace dlib ...@@ -54,6 +54,14 @@ namespace dlib
decision_function objects with fewer support vectors. decision_function objects with fewer support vectors.
- The reduced decision functions that are output will have at most - The reduced decision functions that are output will have at most
num_sv support vectors. num_sv support vectors.
- #get_kernel() == trainer.get_kernel()
!*/
const kernel_type& get_kernel (
) const;
/*!
ensures
- returns the kernel used by this trainer object
!*/ !*/
template < template <
...@@ -140,12 +148,24 @@ namespace dlib ...@@ -140,12 +148,24 @@ namespace dlib
/*! /*!
requires requires
- num_sv > 0 - num_sv > 0
- eps > 0
ensures ensures
- returns a trainer object that applies post processing to the decision_function - returns a trainer object that applies post processing to the decision_function
objects created by the given trainer object with the goal of creating objects created by the given trainer object with the goal of creating
decision_function objects with fewer support vectors. decision_function objects with fewer support vectors.
- The reduced decision functions that are output will have at most - The reduced decision functions that are output will have at most
num_sv support vectors. num_sv support vectors.
- the gradient based optimization will continue until the change in the
objective function is less than eps. So smaller values of eps will
give better results but take longer to compute.
- #get_kernel() == trainer.get_kernel()
!*/
const kernel_type& get_kernel (
) const;
/*!
ensures
- returns the kernel used by this trainer object
!*/ !*/
template < template <
...@@ -184,6 +204,7 @@ namespace dlib ...@@ -184,6 +204,7 @@ namespace dlib
- trainer_type == some kind of trainer object that creates decision_function - trainer_type == some kind of trainer object that creates decision_function
objects (e.g. svm_nu_trainer) objects (e.g. svm_nu_trainer)
- kernel_derivative<trainer_type::kernel_type> is defined - kernel_derivative<trainer_type::kernel_type> is defined
- eps > 0
ensures ensures
- returns a reduced_decision_function_trainer2 object that has been - returns a reduced_decision_function_trainer2 object that has been
instantiated with the given arguments. instantiated with the given arguments.
......
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