Commit 1595f37a authored by Davis King's avatar Davis King

Made the reduced trainers copyable so that they can be used

with the threaded cross validation functions.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402448
parent a49a751c
...@@ -31,6 +31,9 @@ namespace dlib ...@@ -31,6 +31,9 @@ namespace dlib
typedef typename trainer_type::mem_manager_type mem_manager_type; typedef typename trainer_type::mem_manager_type mem_manager_type;
typedef typename trainer_type::trained_function_type trained_function_type; typedef typename trainer_type::trained_function_type trained_function_type;
reduced_decision_function_trainer (
) :num_sv(0) {}
reduced_decision_function_trainer ( reduced_decision_function_trainer (
const trainer_type& trainer_, const trainer_type& trainer_,
const unsigned long num_sv_ const unsigned long num_sv_
...@@ -61,6 +64,11 @@ namespace dlib ...@@ -61,6 +64,11 @@ namespace dlib
const in_scalar_vector_type& y const in_scalar_vector_type& y
) const ) const
{ {
// make sure requires clause is not broken
DLIB_ASSERT(num_sv > 0,
"\t reduced_decision_function_trainer::train(x,y)"
<< "\n\t You have tried to use an uninitialized version of this object"
<< "\n\t num_sv: " << num_sv );
return do_train(vector_to_matrix(x), vector_to_matrix(y)); return do_train(vector_to_matrix(x), vector_to_matrix(y));
} }
...@@ -142,8 +150,8 @@ namespace dlib ...@@ -142,8 +150,8 @@ namespace dlib
// ------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------
const trainer_type& trainer; trainer_type trainer;
const unsigned long num_sv; unsigned long num_sv;
}; // end of class reduced_decision_function_trainer }; // end of class reduced_decision_function_trainer
...@@ -181,6 +189,7 @@ namespace dlib ...@@ -181,6 +189,7 @@ namespace dlib
typedef typename trainer_type::mem_manager_type mem_manager_type; typedef typename trainer_type::mem_manager_type mem_manager_type;
typedef typename trainer_type::trained_function_type trained_function_type; typedef typename trainer_type::trained_function_type trained_function_type;
reduced_decision_function_trainer2 () : num_sv(0) {}
reduced_decision_function_trainer2 ( reduced_decision_function_trainer2 (
const trainer_type& trainer_, const trainer_type& trainer_,
const long num_sv_, const long num_sv_,
...@@ -216,6 +225,11 @@ namespace dlib ...@@ -216,6 +225,11 @@ namespace dlib
const in_scalar_vector_type& y const in_scalar_vector_type& y
) const ) const
{ {
// make sure requires clause is not broken
DLIB_ASSERT(num_sv > 0,
"\t reduced_decision_function_trainer2::train(x,y)"
<< "\n\t You have tried to use an uninitialized version of this object"
<< "\n\t num_sv: " << num_sv );
return do_train(vector_to_matrix(x), vector_to_matrix(y)); return do_train(vector_to_matrix(x), vector_to_matrix(y));
} }
...@@ -571,9 +585,9 @@ namespace dlib ...@@ -571,9 +585,9 @@ namespace dlib
// ------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------
const trainer_type& trainer; trainer_type trainer;
const long num_sv; long num_sv;
const double eps; double eps;
}; // end of class reduced_decision_function_trainer2 }; // end of class reduced_decision_function_trainer2
......
...@@ -41,6 +41,15 @@ namespace dlib ...@@ -41,6 +41,15 @@ namespace dlib
typedef typename trainer_type::mem_manager_type mem_manager_type; typedef typename trainer_type::mem_manager_type mem_manager_type;
typedef typename trainer_type::trained_function_type trained_function_type; typedef typename trainer_type::trained_function_type trained_function_type;
reduced_decision_function_trainer (
);
/*!
ensures
- This object is in an uninitialized state. You must
construct a real one with the other constructor and assign it
to this instance before you use this object.
!*/
reduced_decision_function_trainer ( reduced_decision_function_trainer (
const trainer_type& trainer, const trainer_type& trainer,
const unsigned long num_sv const unsigned long num_sv
...@@ -140,6 +149,15 @@ namespace dlib ...@@ -140,6 +149,15 @@ namespace dlib
typedef typename trainer_type::mem_manager_type mem_manager_type; typedef typename trainer_type::mem_manager_type mem_manager_type;
typedef typename trainer_type::trained_function_type trained_function_type; typedef typename trainer_type::trained_function_type trained_function_type;
reduced_decision_function_trainer2 (
);
/*!
ensures
- This object is in an uninitialized state. You must
construct a real one with the other constructor and assign it
to this instance before you use this object.
!*/
reduced_decision_function_trainer2 ( reduced_decision_function_trainer2 (
const trainer_type& trainer, const trainer_type& trainer,
const unsigned long num_sv, const unsigned long num_sv,
......
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