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
d933439a
"examples/git@developer.sourcefind.cn:OpenDAS/dgl.git" did not exist on "6e8f7605187c2699a18e815c646a4f21e456defa"
Commit
d933439a
authored
Nov 03, 2011
by
Davis King
Browse files
Simplified the sequence_labeler interface a bit.
parent
90c9d0be
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
4 deletions
+32
-4
dlib/svm/sequence_labeler.h
dlib/svm/sequence_labeler.h
+16
-1
dlib/svm/sequence_labeler_abstract.h
dlib/svm/sequence_labeler_abstract.h
+15
-2
examples/sequence_labeler_ex.cpp
examples/sequence_labeler_ex.cpp
+1
-1
No files found.
dlib/svm/sequence_labeler.h
View file @
d933439a
...
@@ -186,6 +186,21 @@ namespace dlib
...
@@ -186,6 +186,21 @@ namespace dlib
weights
=
0
;
weights
=
0
;
}
}
explicit
sequence_labeler
(
const
matrix
<
double
,
0
,
1
>&
weights_
)
:
weights
(
weights_
)
{
// make sure requires clause is not broken
DLIB_ASSERT
(
fe
.
num_features
()
==
static_cast
<
unsigned
long
>
(
weights_
.
size
()),
"
\t
sequence_labeler::sequence_labeler(weights_)"
<<
"
\n\t
These sizes should match"
<<
"
\n\t
fe.num_features(): "
<<
fe
.
num_features
()
<<
"
\n\t
weights_.size(): "
<<
weights_
.
size
()
<<
"
\n\t
this: "
<<
this
);
}
sequence_labeler
(
sequence_labeler
(
const
feature_extractor
&
fe_
,
const
feature_extractor
&
fe_
,
const
matrix
<
double
,
0
,
1
>&
weights_
const
matrix
<
double
,
0
,
1
>&
weights_
...
@@ -195,7 +210,7 @@ namespace dlib
...
@@ -195,7 +210,7 @@ namespace dlib
{
{
// make sure requires clause is not broken
// make sure requires clause is not broken
DLIB_ASSERT
(
fe_
.
num_features
()
==
static_cast
<
unsigned
long
>
(
weights_
.
size
()),
DLIB_ASSERT
(
fe_
.
num_features
()
==
static_cast
<
unsigned
long
>
(
weights_
.
size
()),
"
\t
sequence_labeler::sequence_labeler()"
"
\t
sequence_labeler::sequence_labeler(
fe_,weights_
)"
<<
"
\n\t
These sizes should match"
<<
"
\n\t
These sizes should match"
<<
"
\n\t
fe_.num_features(): "
<<
fe_
.
num_features
()
<<
"
\n\t
fe_.num_features(): "
<<
fe_
.
num_features
()
<<
"
\n\t
weights_.size(): "
<<
weights_
.
size
()
<<
"
\n\t
weights_.size(): "
<<
weights_
.
size
()
...
...
dlib/svm/sequence_labeler_abstract.h
View file @
d933439a
...
@@ -196,9 +196,22 @@ namespace dlib
...
@@ -196,9 +196,22 @@ namespace dlib
);
);
/*!
/*!
ensures
ensures
- #get_weights().size() == fe.num_features()
- #get_feature_extractor() == feature_extractor()
(i.e. it will have its default value)
- #get_weights().size() == #get_feature_extractor().num_features()
- #get_weights() == 0
- #get_weights() == 0
- #get_feature_extractor() will have an initial value for its type
!*/
explicit
sequence_labeler
(
const
matrix
<
double
,
0
,
1
>&
weights
);
/*!
requires
- feature_extractor().num_features() == weights.size()
ensures
- #get_feature_extractor() == feature_extractor()
(i.e. it will have its default value)
- #get_weights() == weights
!*/
!*/
sequence_labeler
(
sequence_labeler
(
...
...
examples/sequence_labeler_ex.cpp
View file @
d933439a
...
@@ -162,7 +162,7 @@ int main()
...
@@ -162,7 +162,7 @@ int main()
matrix
<
double
,
0
,
1
>
true_hmm_model_weights
=
log
(
join_cols
(
reshape_to_column_vector
(
transition_probabilities
),
matrix
<
double
,
0
,
1
>
true_hmm_model_weights
=
log
(
join_cols
(
reshape_to_column_vector
(
transition_probabilities
),
reshape_to_column_vector
(
emission_probabilities
)));
reshape_to_column_vector
(
emission_probabilities
)));
sequence_labeler
<
feature_extractor
>
labeler_true
(
feature_extractor
(),
true_hmm_model_weights
);
sequence_labeler
<
feature_extractor
>
labeler_true
(
true_hmm_model_weights
);
confusion_matrix
=
test_sequence_labeler
(
labeler_true
,
samples
,
labels
);
confusion_matrix
=
test_sequence_labeler
(
labeler_true
,
samples
,
labels
);
cout
<<
"
\n
True HMM model: "
<<
endl
;
cout
<<
"
\n
True HMM model: "
<<
endl
;
...
...
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