Commit 0ce66e9a authored by Davis King's avatar Davis King

I just did some code cleanup. In particular, I added a typedef to the decision function

objects to allow you to get the kernel type out of them.  I also removed some extraneous
get_kernel() functions from some of the trainer adapter classes since they really aren't
needed.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%403036
parent 33a22432
......@@ -23,6 +23,7 @@ namespace dlib
>
struct decision_function
{
typedef K kernel_type;
typedef typename K::scalar_type scalar_type;
typedef typename K::sample_type sample_type;
typedef typename K::mem_manager_type mem_manager_type;
......@@ -134,6 +135,7 @@ namespace dlib
>
struct probabilistic_decision_function
{
typedef K kernel_type;
typedef typename K::scalar_type scalar_type;
typedef typename K::sample_type sample_type;
typedef typename K::mem_manager_type mem_manager_type;
......@@ -233,6 +235,7 @@ namespace dlib
>
struct distance_function
{
typedef K kernel_type;
typedef typename K::scalar_type scalar_type;
typedef typename K::sample_type sample_type;
typedef typename K::mem_manager_type mem_manager_type;
......@@ -364,6 +367,7 @@ namespace dlib
>
struct normalized_function
{
typedef typename function_type::kernel_type kernel_type;
typedef typename function_type::scalar_type scalar_type;
typedef typename function_type::sample_type sample_type;
typedef typename function_type::mem_manager_type mem_manager_type;
......
......@@ -31,6 +31,7 @@ namespace dlib
learned by a kernel based learning algorithm.
!*/
typedef K kernel_type;
typedef typename K::scalar_type scalar_type;
typedef typename K::sample_type sample_type;
typedef typename K::mem_manager_type mem_manager_type;
......@@ -137,6 +138,7 @@ namespace dlib
estimate of the probability that a given sample is in the +1 class.
!*/
typedef K kernel_type;
typedef typename K::scalar_type scalar_type;
typedef typename K::sample_type sample_type;
typedef typename K::mem_manager_type mem_manager_type;
......@@ -242,6 +244,7 @@ namespace dlib
represents to points in input space.
!*/
typedef K kernel_type;
typedef typename K::scalar_type scalar_type;
typedef typename K::sample_type sample_type;
typedef typename K::mem_manager_type mem_manager_type;
......@@ -381,6 +384,7 @@ namespace dlib
off to the contained function object.
!*/
typedef typename function_type::kernel_type kernel_type;
typedef typename function_type::scalar_type scalar_type;
typedef typename function_type::sample_type sample_type;
typedef typename function_type::mem_manager_type mem_manager_type;
......
......@@ -295,12 +295,6 @@ namespace dlib
);
}
const kernel_type get_kernel (
) const
{
return trainer.get_kernel();
}
const scalar_type get_min_learning_rate (
) const
{
......
......@@ -319,7 +319,6 @@ namespace dlib
ensures
- returns a batch trainer object that uses the given online_trainer object
to train a decision function.
- #get_kernel() == trainer.get_kernel()
- #get_min_learning_rate() == min_learning_rate_
- if (verbose_ == true) then
- this object will output status messages to standard out while
......@@ -334,13 +333,6 @@ namespace dlib
before this object considers training to be complete.
!*/
const kernel_type get_kernel (
) const;
/*!
ensures
- returns the kernel used by this trainer object
!*/
template <
typename in_sample_vector_type,
typename in_scalar_vector_type
......
......@@ -49,12 +49,6 @@ namespace dlib
);
}
const kernel_type& get_kernel (
) const
{
return trainer.get_kernel();
}
template <
typename in_sample_vector_type,
typename in_scalar_vector_type
......@@ -89,7 +83,7 @@ namespace dlib
const decision_function<kernel_type> dec_funct = trainer.train(x,y);
// now find a linearly independent subset of the training points of num_sv points.
linearly_independent_subset_finder<kernel_type> lisf(trainer.get_kernel(), num_sv);
linearly_independent_subset_finder<kernel_type> lisf(dec_funct.kernel_function, num_sv);
for (long i = 0; i < x.nr(); ++i)
{
lisf.add(x(i));
......@@ -107,7 +101,7 @@ namespace dlib
matrix<scalar_type, 0, 0, mem_manager_type> K_inv(num, num);
matrix<scalar_type, 0, 0, mem_manager_type> K(num, dec_funct.alpha.size());
const kernel_type kernel(trainer.get_kernel());
const kernel_type kernel(dec_funct.kernel_function);
for (long r = 0; r < K_inv.nr(); ++r)
{
......@@ -210,12 +204,6 @@ namespace dlib
);
}
const kernel_type& get_kernel (
) const
{
return trainer.get_kernel();
}
template <
typename in_sample_vector_type,
typename in_scalar_vector_type
......@@ -507,7 +495,7 @@ namespace dlib
const decision_function<kernel_type> dec_funct = trainer.train(x,y);
// now find a linearly independent subset of the training points of num_sv points.
linearly_independent_subset_finder<kernel_type> lisf(trainer.get_kernel(), num_sv);
linearly_independent_subset_finder<kernel_type> lisf(dec_funct.kernel_function, num_sv);
for (long i = 0; i < x.nr(); ++i)
{
lisf.add(x(i));
......@@ -525,7 +513,7 @@ namespace dlib
matrix<scalar_type, 0, 0, mem_manager_type> K_inv(num, num);
matrix<scalar_type, 0, 0, mem_manager_type> K(num, dec_funct.alpha.size());
const kernel_type kernel(trainer.get_kernel());
const kernel_type kernel(dec_funct.kernel_function);
for (long r = 0; r < K_inv.nr(); ++r)
{
......
......@@ -63,14 +63,6 @@ namespace dlib
decision_function objects with fewer support vectors.
- The reduced decision functions that are output will have at most
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 <
......@@ -176,14 +168,6 @@ namespace dlib
- 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 <
......
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