Commit bf2f8f81 authored by Davis King's avatar Davis King

Added some missing asserts and cleaned up some things

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402383
parent 94f55bca
...@@ -850,12 +850,24 @@ namespace dlib ...@@ -850,12 +850,24 @@ namespace dlib
cache_size(200), cache_size(200),
eps(0.001) eps(0.001)
{ {
// make sure requires clause is not broken
DLIB_ASSERT(0 < nu && nu <= 1,
"\tsvm_nu_trainer::svm_nu_trainer(kernel,nu)"
<< "\n\t invalid inputs were given to this function"
<< "\n\t nu: " << nu
);
} }
void set_cache_size ( void set_cache_size (
long cache_size_ long cache_size_
) )
{ {
// make sure requires clause is not broken
DLIB_ASSERT(cache_size_ > 0,
"\tvoid svm_nu_trainer::set_cache_size(cache_size_)"
<< "\n\t invalid inputs were given to this function"
<< "\n\t cache_size: " << cache_size_
);
cache_size = cache_size_; cache_size = cache_size_;
} }
...@@ -869,6 +881,12 @@ namespace dlib ...@@ -869,6 +881,12 @@ namespace dlib
scalar_type eps_ scalar_type eps_
) )
{ {
// make sure requires clause is not broken
DLIB_ASSERT(eps_ > 0,
"\tvoid svm_nu_trainer::set_epsilon(eps_)"
<< "\n\t invalid inputs were given to this function"
<< "\n\t eps: " << eps_
);
eps = eps_; eps = eps_;
} }
...@@ -895,6 +913,12 @@ namespace dlib ...@@ -895,6 +913,12 @@ namespace dlib
scalar_type nu_ scalar_type nu_
) )
{ {
// make sure requires clause is not broken
DLIB_ASSERT(0 < nu_ && nu_ <= 1,
"\tvoid svm_nu_trainer::set_nu(nu_)"
<< "\n\t invalid inputs were given to this function"
<< "\n\t nu: " << nu_
);
nu = nu_; nu = nu_;
} }
...@@ -1387,6 +1411,14 @@ namespace dlib ...@@ -1387,6 +1411,14 @@ namespace dlib
scalar_type eps; scalar_type eps;
}; // end of class svm_nu_trainer }; // end of class svm_nu_trainer
// ----------------------------------------------------------------------------------------
template <typename K>
void swap (
svm_nu_trainer<K>& a,
svm_nu_trainer<K>& b
) { a.swap(b); }
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
} }
......
...@@ -157,9 +157,9 @@ namespace dlib ...@@ -157,9 +157,9 @@ namespace dlib
ensures ensures
- returns the number of megabytes of cache this object will use - returns the number of megabytes of cache this object will use
when it performs training via the this->train() function. when it performs training via the this->train() function.
(bigger values of this may make training go faster but doesn't affect (bigger values of this may make training go faster but won't affect
the result. However, too big a value will cause you to run out of the result. However, too big a value will cause you to run out of
memory obviously.) memory, obviously.)
!*/ !*/
void set_epsilon ( void set_epsilon (
...@@ -252,6 +252,15 @@ namespace dlib ...@@ -252,6 +252,15 @@ namespace dlib
!*/ !*/
}; };
template <typename K>
void swap (
svm_nu_trainer<K>& a,
svm_nu_trainer<K>& b
) { a.swap(b); }
/*!
provides a global swap
!*/
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
template < 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