Commit ce517cfa authored by Davis King's avatar Davis King

Fixed initialization bug in the new SVM L2 mode.

parent 4203da2b
...@@ -228,12 +228,17 @@ namespace dlib ...@@ -228,12 +228,17 @@ namespace dlib
private: private:
template < template <
typename in_sample_vector_type typename in_sample_vector_type,
typename in_scalar_vector_type
> >
void init( void init(
const in_sample_vector_type& x, const in_sample_vector_type& x,
const in_scalar_vector_type& y,
bool have_bias_, bool have_bias_,
bool last_weight_1_ bool last_weight_1_,
bool do_svm_l2_,
scalar_type Cpos,
scalar_type Cneg
) )
{ {
const long new_dims = max_index_plus_one(x); const long new_dims = max_index_plus_one(x);
...@@ -346,6 +351,14 @@ namespace dlib ...@@ -346,6 +351,14 @@ namespace dlib
{ {
index.push_back(i); index.push_back(i);
} }
if (do_svm_l2_)
{
if (y(i) > 0)
Q.back() += 1/(2*Cpos);
else
Q.back() += 1/(2*Cneg);
}
} }
if (last_weight_1) if (last_weight_1)
...@@ -499,7 +512,7 @@ namespace dlib ...@@ -499,7 +512,7 @@ namespace dlib
} }
#endif #endif
state.init(x,have_bias,last_weight_1); state.init(x,y,have_bias,last_weight_1,do_svm_l2,Cpos,Cneg);
std::vector<scalar_type>& alpha = state.alpha; std::vector<scalar_type>& alpha = state.alpha;
scalar_vector_type& w = state.w; scalar_vector_type& w = state.w;
......
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