Commit a929b066 authored by Davis King's avatar Davis King

Added a function to set the minimum tolerance after the object has been constructed.

Also made the spec more clear.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%403664
parent 78e48695
...@@ -98,6 +98,20 @@ namespace dlib ...@@ -98,6 +98,20 @@ namespace dlib
return min_tolerance; return min_tolerance;
} }
void set_minimum_tolerance (
scalar_type min_tol
)
{
// make sure requires clause is not broken
DLIB_ASSERT(min_tol > 0,
"\tlinearly_independent_subset_finder::set_minimum_tolerance()"
<< "\n\tinvalid argument to this function"
<< "\n\tmin_tol: " << min_tol
<< "\n\tthis: " << this
);
min_tolerance = min_tol;
}
void clear_dictionary () void clear_dictionary ()
{ {
dictionary.clear(); dictionary.clear();
......
...@@ -24,19 +24,24 @@ namespace dlib ...@@ -24,19 +24,24 @@ namespace dlib
WHAT THIS OBJECT REPRESENTS WHAT THIS OBJECT REPRESENTS
This is an implementation of an online algorithm for recursively finding a This is an implementation of an online algorithm for recursively finding a
set of linearly independent vectors in a kernel induced feature space. To set (aka dictionary) of linearly independent vectors in a kernel induced
use it you decide how large you would like the set to be and then you feed it feature space. To use it you decide how large you would like the dictionary
sample points. to be and then you feed it sample points.
Each time you present it with a new sample point (via this->add()) it either The implementation uses the Approximately Linearly Dependent metric described
keeps the current set of independent points unchanged, or if the new point in the paper The Kernel Recursive Least Squares Algorithm by Yaakov Engel to
is "more linearly independent" than one of the points it already has, decide which points are more linearly independent than others. The metric is
it replaces the weakly linearly independent point with the new one. simply the squared distance between a test point and the subspace spanned by
the current set of dictionary vectors.
This object uses the Approximately Linearly Dependent metric described in the paper Each time you present this object with a new sample point (via this->add())
The Kernel Recursive Least Squares Algorithm by Yaakov Engel to decide which it calculates the projection distance and if it is sufficiently large then this
points are more linearly independent than others. new point is included into the current dictionary. Note that this object can
be configured to have a maximum size. Once the max dictionary size is reached
each new point kicks out a previous point. This is done by selecting the current
dictionary vector that has the smallest projection error onto the others. That
is, the "least linearly independent" vector is removed to make room for the
new one.
!*/ !*/
public: public:
...@@ -92,7 +97,7 @@ namespace dlib ...@@ -92,7 +97,7 @@ namespace dlib
- returns the minimum tolerance to use for the approximately linearly dependent - returns the minimum tolerance to use for the approximately linearly dependent
test used for dictionary vector selection (see KRLS paper for ALD details). test used for dictionary vector selection (see KRLS paper for ALD details).
In other words, this is the minimum threshold for how linearly independent In other words, this is the minimum threshold for how linearly independent
a sample must be for it to even be considered for addition to the dictionary. a sample must be for it to be considered for addition to the dictionary.
Moreover, bigger values of this field will make the algorithm run faster but Moreover, bigger values of this field will make the algorithm run faster but
might give less accurate results. might give less accurate results.
- The exact meaning of the tolerance parameter is the following: - The exact meaning of the tolerance parameter is the following:
...@@ -105,6 +110,16 @@ namespace dlib ...@@ -105,6 +110,16 @@ namespace dlib
of the dictionary. of the dictionary.
!*/ !*/
void set_minimum_tolerance (
scalar_type min_tolerance
);
/*!
requires
- min_tolerance > 0
ensures
- #minimum_tolerance() == min_tol
!*/
void clear_dictionary ( void clear_dictionary (
); );
/*! /*!
...@@ -117,7 +132,7 @@ namespace dlib ...@@ -117,7 +132,7 @@ namespace dlib
); );
/*! /*!
ensures ensures
- if (x is linearly independent of the vectors already in this object) then - if (x is sufficiently linearly independent of the vectors already in this object) then
- adds x into the dictionary - adds x into the dictionary
- (*this)[#dictionary_size()-1] == x - (*this)[#dictionary_size()-1] == x
- returns true - returns true
......
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