Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
ce517cfa
Commit
ce517cfa
authored
Feb 18, 2016
by
Davis King
Browse files
Fixed initialization bug in the new SVM L2 mode.
parent
4203da2b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
3 deletions
+16
-3
dlib/svm/svm_c_linear_dcd_trainer.h
dlib/svm/svm_c_linear_dcd_trainer.h
+16
-3
No files found.
dlib/svm/svm_c_linear_dcd_trainer.h
View file @
ce517cfa
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment