Commit f76ce334 authored by Davis King's avatar Davis King

Renamed the get_tolerance() and get_max_dictionary_size() functions

so that they don't start with get_ to be a little more consistent.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402314
parent 3e1edfaa
...@@ -40,20 +40,20 @@ namespace dlib ...@@ -40,20 +40,20 @@ namespace dlib
unsigned long max_dictionary_size_ = 1000000 unsigned long max_dictionary_size_ = 1000000
) : ) :
kernel(kernel_), kernel(kernel_),
tolerance(tolerance_), my_tolerance(tolerance_),
max_dictionary_size(max_dictionary_size_) my_max_dictionary_size(max_dictionary_size_)
{ {
clear_dictionary(); clear_dictionary();
} }
scalar_type get_tolerance() const scalar_type tolerance() const
{ {
return tolerance; return my_tolerance;
} }
unsigned long get_max_dictionary_size() const unsigned long max_dictionary_size() const
{ {
return max_dictionary_size; return my_max_dictionary_size;
} }
void clear_dictionary () void clear_dictionary ()
...@@ -133,7 +133,7 @@ namespace dlib ...@@ -133,7 +133,7 @@ namespace dlib
alpha.swap(item.alpha); alpha.swap(item.alpha);
K_inv.swap(item.K_inv); K_inv.swap(item.K_inv);
K.swap(item.K); K.swap(item.K);
exchange(tolerance, item.tolerance); exchange(my_tolerance, item.my_tolerance);
exchange(samples_seen, item.samples_seen); exchange(samples_seen, item.samples_seen);
exchange(bias, item.bias); exchange(bias, item.bias);
a.swap(item.a); a.swap(item.a);
...@@ -150,7 +150,7 @@ namespace dlib ...@@ -150,7 +150,7 @@ namespace dlib
serialize(item.alpha, out); serialize(item.alpha, out);
serialize(item.K_inv, out); serialize(item.K_inv, out);
serialize(item.K, out); serialize(item.K, out);
serialize(item.tolerance, out); serialize(item.my_tolerance, out);
serialize(item.samples_seen, out); serialize(item.samples_seen, out);
serialize(item.bias, out); serialize(item.bias, out);
} }
...@@ -162,7 +162,7 @@ namespace dlib ...@@ -162,7 +162,7 @@ namespace dlib
deserialize(item.alpha, in); deserialize(item.alpha, in);
deserialize(item.K_inv, in); deserialize(item.K_inv, in);
deserialize(item.K, in); deserialize(item.K, in);
deserialize(item.tolerance, in); deserialize(item.my_tolerance, in);
deserialize(item.samples_seen, in); deserialize(item.samples_seen, in);
deserialize(item.bias, in); deserialize(item.bias, in);
} }
...@@ -209,9 +209,9 @@ namespace dlib ...@@ -209,9 +209,9 @@ namespace dlib
// if this new vector isn't approximately linearly dependent on the vectors // if this new vector isn't approximately linearly dependent on the vectors
// in our dictionary. // in our dictionary.
if (std::abs(delta) > tolerance) if (std::abs(delta) > my_tolerance)
{ {
if (dictionary.size() >= max_dictionary_size) if (dictionary.size() >= my_max_dictionary_size)
{ {
// We need to remove one of the old members of the dictionary before // We need to remove one of the old members of the dictionary before
// we proceed with adding a new one. So remove the oldest one. // we proceed with adding a new one. So remove the oldest one.
...@@ -332,8 +332,8 @@ namespace dlib ...@@ -332,8 +332,8 @@ namespace dlib
matrix<scalar_type,0,0,mem_manager_type> K_inv; matrix<scalar_type,0,0,mem_manager_type> K_inv;
matrix<scalar_type,0,0,mem_manager_type> K; matrix<scalar_type,0,0,mem_manager_type> K;
scalar_type tolerance; scalar_type my_tolerance;
unsigned long max_dictionary_size; unsigned long my_max_dictionary_size;
scalar_type samples_seen; scalar_type samples_seen;
scalar_type bias; scalar_type bias;
......
...@@ -57,19 +57,19 @@ namespace dlib ...@@ -57,19 +57,19 @@ namespace dlib
/*! /*!
ensures ensures
- this object is properly initialized - this object is properly initialized
- #get_tolerance() == tolerance_ - #tolerance() == tolerance_
- #get_decision_function().kernel_function == kernel_ - #get_decision_function().kernel_function == kernel_
(i.e. this object will use the given kernel function) (i.e. this object will use the given kernel function)
- #get_max_dictionary_size() == max_dictionary_size_ - #max_dictionary_size() == max_dictionary_size_
!*/ !*/
unsigned long get_max_dictionary_size( unsigned long max_dictionary_size(
) const; ) const;
/*! /*!
ensures ensures
- returns the maximum number of dictionary vectors this object - returns the maximum number of dictionary vectors this object
will use at a time. That is, dictionary_size() will never be will use at a time. That is, dictionary_size() will never be
greater than get_max_dictionary_size(). greater than max_dictionary_size().
!*/ !*/
scalar_type samples_trained ( scalar_type samples_trained (
...@@ -79,7 +79,7 @@ namespace dlib ...@@ -79,7 +79,7 @@ namespace dlib
- returns the number of samples this object has been trained on so far - returns the number of samples this object has been trained on so far
!*/ !*/
scalar_type get_tolerance( scalar_type tolerance(
) const; ) const;
/*! /*!
ensures ensures
......
...@@ -35,20 +35,20 @@ namespace dlib ...@@ -35,20 +35,20 @@ namespace dlib
unsigned long max_dictionary_size_ = 1000000 unsigned long max_dictionary_size_ = 1000000
) : ) :
kernel(kernel_), kernel(kernel_),
tolerance(tolerance_), my_tolerance(tolerance_),
max_dictionary_size(max_dictionary_size_) my_max_dictionary_size(max_dictionary_size_)
{ {
clear_dictionary(); clear_dictionary();
} }
scalar_type get_tolerance() const scalar_type tolerance() const
{ {
return tolerance; return my_tolerance;
} }
unsigned long get_max_dictionary_size() const unsigned long max_dictionary_size() const
{ {
return max_dictionary_size; return my_max_dictionary_size;
} }
void clear_dictionary () void clear_dictionary ()
...@@ -106,9 +106,9 @@ namespace dlib ...@@ -106,9 +106,9 @@ namespace dlib
// if this new vector isn't approximately linearly dependent on the vectors // if this new vector isn't approximately linearly dependent on the vectors
// in our dictionary. // in our dictionary.
if (std::abs(delta) > tolerance) if (std::abs(delta) > my_tolerance)
{ {
if (dictionary.size() >= max_dictionary_size) if (dictionary.size() >= my_max_dictionary_size)
{ {
// We need to remove one of the old members of the dictionary before // We need to remove one of the old members of the dictionary before
// we proceed with adding a new one. So remove the oldest one. // we proceed with adding a new one. So remove the oldest one.
...@@ -199,12 +199,12 @@ namespace dlib ...@@ -199,12 +199,12 @@ namespace dlib
K_inv.swap(item.K_inv); K_inv.swap(item.K_inv);
K.swap(item.K); K.swap(item.K);
P.swap(item.P); P.swap(item.P);
exchange(tolerance, item.tolerance); exchange(my_tolerance, item.my_tolerance);
q.swap(item.q); q.swap(item.q);
a.swap(item.a); a.swap(item.a);
k.swap(item.k); k.swap(item.k);
temp_matrix.swap(item.temp_matrix); temp_matrix.swap(item.temp_matrix);
exchange(max_dictionary_size, item.max_dictionary_size); exchange(my_max_dictionary_size, item.my_max_dictionary_size);
} }
unsigned long dictionary_size ( unsigned long dictionary_size (
...@@ -229,8 +229,8 @@ namespace dlib ...@@ -229,8 +229,8 @@ namespace dlib
serialize(item.K_inv, out); serialize(item.K_inv, out);
serialize(item.K, out); serialize(item.K, out);
serialize(item.P, out); serialize(item.P, out);
serialize(item.tolerance, out); serialize(item.my_tolerance, out);
serialize(item.max_dictionary_size, out); serialize(item.my_max_dictionary_size, out);
} }
friend void deserialize(krls& item, std::istream& in) friend void deserialize(krls& item, std::istream& in)
...@@ -241,8 +241,8 @@ namespace dlib ...@@ -241,8 +241,8 @@ namespace dlib
deserialize(item.K_inv, in); deserialize(item.K_inv, in);
deserialize(item.K, in); deserialize(item.K, in);
deserialize(item.P, in); deserialize(item.P, in);
deserialize(item.tolerance, in); deserialize(item.my_tolerance, in);
deserialize(item.max_dictionary_size, in); deserialize(item.my_max_dictionary_size, in);
} }
private: private:
...@@ -308,8 +308,8 @@ namespace dlib ...@@ -308,8 +308,8 @@ namespace dlib
matrix<scalar_type,0,0,mem_manager_type> K; matrix<scalar_type,0,0,mem_manager_type> K;
matrix<scalar_type,0,0,mem_manager_type> P; matrix<scalar_type,0,0,mem_manager_type> P;
scalar_type tolerance; scalar_type my_tolerance;
unsigned long max_dictionary_size; unsigned long my_max_dictionary_size;
// temp variables here just so we don't have to reconstruct them over and over. Thus, // temp variables here just so we don't have to reconstruct them over and over. Thus,
......
...@@ -55,13 +55,13 @@ namespace dlib ...@@ -55,13 +55,13 @@ namespace dlib
/*! /*!
ensures ensures
- this object is properly initialized - this object is properly initialized
- #get_tolerance() == tolerance_ - #tolerance() == tolerance_
- #get_decision_function().kernel_function == kernel_ - #get_decision_function().kernel_function == kernel_
(i.e. this object will use the given kernel function) (i.e. this object will use the given kernel function)
- #get_max_dictionary_size() == max_dictionary_size_ - #max_dictionary_size() == max_dictionary_size_
!*/ !*/
scalar_type get_tolerance( scalar_type tolerance(
) const; ) const;
/*! /*!
ensures ensures
...@@ -74,13 +74,13 @@ namespace dlib ...@@ -74,13 +74,13 @@ namespace dlib
less accurate decision function but also in less support vectors. less accurate decision function but also in less support vectors.
!*/ !*/
unsigned long get_max_dictionary_size( unsigned long max_dictionary_size(
) const; ) const;
/*! /*!
ensures ensures
- returns the maximum number of dictionary vectors this object - returns the maximum number of dictionary vectors this object
will use at a time. That is, dictionary_size() will never be will use at a time. That is, dictionary_size() will never be
greater than get_max_dictionary_size(). greater than max_dictionary_size().
!*/ !*/
void clear_dictionary ( void clear_dictionary (
...@@ -106,7 +106,7 @@ namespace dlib ...@@ -106,7 +106,7 @@ namespace dlib
/*! /*!
ensures ensures
- trains this object that the given x should be mapped to the given y - trains this object that the given x should be mapped to the given y
- if (dictionary_size() == get_max_dictionary_size() and training - if (dictionary_size() == max_dictionary_size() and training
would add another dictionary vector to this object) then would add another dictionary vector to this object) then
- discards the oldest dictionary vector so that we can still - discards the oldest dictionary vector so that we can still
add a new one and remain below the max number of dictionary add a new one and remain below the max number of dictionary
......
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