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
9aecb4c4
Commit
9aecb4c4
authored
Oct 25, 2012
by
Davis King
Browse files
Added the ability to learn non-negative weight vectors to the structural_assignment_trainer
object.
parent
ac4598ae
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
1 deletion
+38
-1
dlib/svm/structural_assignment_trainer.h
dlib/svm/structural_assignment_trainer.h
+19
-1
dlib/svm/structural_assignment_trainer_abstract.h
dlib/svm/structural_assignment_trainer_abstract.h
+19
-0
No files found.
dlib/svm/structural_assignment_trainer.h
View file @
9aecb4c4
...
...
@@ -55,6 +55,16 @@ namespace dlib
return
num_threads
;
}
bool
learns_nonnegative_weights
(
)
const
{
return
learn_nonnegative_weights
;
}
void
set_learns_nonnegative_weights
(
bool
value
)
{
learn_nonnegative_weights
=
value
;
}
void
set_epsilon
(
double
eps_
)
...
...
@@ -183,7 +193,13 @@ namespace dlib
matrix
<
double
,
0
,
1
>
weights
;
solver
(
prob
,
weights
);
unsigned
long
num_nonnegative
=
0
;
if
(
learn_nonnegative_weights
)
{
num_nonnegative
=
fe
.
num_features
();
}
solver
(
prob
,
weights
,
num_nonnegative
);
return
assignment_function
<
feature_extractor
>
(
weights
,
fe
,
force_assignment
);
...
...
@@ -192,6 +208,7 @@ namespace dlib
private:
bool
learn_nonnegative_weights
;
bool
force_assignment
;
double
C
;
oca
solver
;
...
...
@@ -208,6 +225,7 @@ namespace dlib
eps
=
0.1
;
num_threads
=
2
;
max_cache_size
=
40
;
learn_nonnegative_weights
=
false
;
}
feature_extractor
fe
;
...
...
dlib/svm/structural_assignment_trainer_abstract.h
View file @
9aecb4c4
...
...
@@ -52,6 +52,7 @@ namespace dlib
- #get_max_cache_size() == 40
- #get_feature_extractor() == a default initialized feature_extractor
- #forces_assignment() == false
- #learns_nonnegative_weights() == false
!*/
explicit
structural_assignment_trainer
(
...
...
@@ -66,6 +67,7 @@ namespace dlib
- #get_max_cache_size() == 40
- #get_feature_extractor() == fe
- #forces_assignment() == false
- #learns_nonnegative_weights() == false
!*/
const
feature_extractor
&
get_feature_extractor
(
...
...
@@ -162,6 +164,23 @@ namespace dlib
- returns a copy of the optimizer used to solve the structural SVM problem.
!*/
bool
learns_nonnegative_weights
(
)
const
;
/*!
ensures
- The output of training is a weight vector that defines the behavior of an
assignment_function object. If learns_nonnegative_weights() == true then
the resulting weight vector will always have non-negative entries.
!*/
void
set_learns_nonnegative_weights
(
bool
value
);
/*!
ensures
- #learns_nonnegative_weights() == value
!*/
void
set_c
(
double
C
);
...
...
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