Commit 81d2baa2 authored by Davis King's avatar Davis King

Removed the requirement that the lisf be non-empty when used to load an

EKM.  Instead, the load() function now will accept non-empty lisf objects
and throw a non-fatal exception.  This behavior should be slightly less
surprising to users, especially since certain degenerate datasets can give
rise to empty lisf objects when you might not expect it.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%404111
parent 1dbf1d62
...@@ -76,12 +76,16 @@ namespace dlib ...@@ -76,12 +76,16 @@ namespace dlib
const linearly_independent_subset_finder<kernel_type>& lisf const linearly_independent_subset_finder<kernel_type>& lisf
) )
{ {
// make sure requires clause is not broken if (lisf.size() == 0)
DLIB_ASSERT(lisf.size() > 0, {
"\tvoid empirical_kernel_map::load(linearly_independent_subset_finder)" std::ostringstream sout;
<< "\n\t You have to give a non-empty set of basis_samples" sout << "An empty linearly_independent_subset_finder was supplied to the\n"
<< "\n\t this: " << this << "empirical_kernel_map::load() function. One reason this might occur\n"
); << "is if your dataset contains only zero vectors (or vectors \n"
<< "approximately zero).\n";
clear();
throw empirical_kernel_map_error(sout.str());
}
kernel = lisf.get_kernel(); kernel = lisf.get_kernel();
weights = trans(chol(lisf.get_inv_kernel_marix())); weights = trans(chol(lisf.get_inv_kernel_marix()));
......
...@@ -152,8 +152,6 @@ namespace dlib ...@@ -152,8 +152,6 @@ namespace dlib
const linearly_independent_subset_finder<kernel_type>& lisf const linearly_independent_subset_finder<kernel_type>& lisf
); );
/*! /*!
requires
- lisf.dictionary_size() > 0
ensures ensures
- #out_vector_size() == lisf.dictionary_size() - #out_vector_size() == lisf.dictionary_size()
- #basis_size() == lisf.dictionary_size() - #basis_size() == lisf.dictionary_size()
...@@ -169,7 +167,8 @@ namespace dlib ...@@ -169,7 +167,8 @@ namespace dlib
- for all valid i: (*this)[i] == lisf[i] - for all valid i: (*this)[i] == lisf[i]
throws throws
- empirical_kernel_map_error - empirical_kernel_map_error
This exception is thrown if we are unable to create a kernel map. This exception is thrown if we are unable to create a kernel map.
E.g. if the lisf.size() == 0.
If this happens then this object will revert back to its initial value. If this happens then this object will revert back to its initial value.
!*/ !*/
......
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