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
1e1d7fc8
Commit
1e1d7fc8
authored
Dec 08, 2011
by
Davis King
Browse files
Added the contains_invalid_labeling() routine.
parent
ea26c37b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
114 additions
and
0 deletions
+114
-0
dlib/svm/sequence_labeler.h
dlib/svm/sequence_labeler.h
+69
-0
dlib/svm/sequence_labeler_abstract.h
dlib/svm/sequence_labeler_abstract.h
+45
-0
No files found.
dlib/svm/sequence_labeler.h
View file @
1e1d7fc8
...
@@ -123,7 +123,76 @@ namespace dlib
...
@@ -123,7 +123,76 @@ namespace dlib
}
}
}
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
typename
feature_extractor
>
typename
enable_if
<
dlib
::
impl
::
has_reject_labeling
<
feature_extractor
>
,
bool
>::
type
contains_invalid_labeling
(
const
feature_extractor
&
fe
,
const
std
::
vector
<
typename
feature_extractor
::
sample_type
>&
x
,
const
std
::
vector
<
unsigned
long
>&
y
)
{
if
(
x
.
size
()
!=
y
.
size
())
return
true
;
matrix
<
unsigned
long
,
0
,
1
>
node_states
;
for
(
unsigned
long
i
=
0
;
i
<
x
.
size
();
++
i
)
{
node_states
.
set_size
(
std
::
min
(
fe
.
order
(),
i
)
+
1
);
for
(
unsigned
long
j
=
0
;
j
<
node_states
.
size
();
++
j
)
node_states
(
j
)
=
y
[
i
-
j
];
if
(
fe
.
reject_labeling
(
x
,
node_states
,
i
))
return
true
;
}
return
false
;
}
// ----------------------------------------------------------------------------------------
template
<
typename
feature_extractor
>
typename
disable_if
<
dlib
::
impl
::
has_reject_labeling
<
feature_extractor
>
,
bool
>::
type
contains_invalid_labeling
(
const
feature_extractor
&
,
const
std
::
vector
<
typename
feature_extractor
::
sample_type
>&
x
,
const
std
::
vector
<
unsigned
long
>&
y
)
{
if
(
x
.
size
()
!=
y
.
size
())
return
true
;
return
false
;
}
// ----------------------------------------------------------------------------------------
template
<
typename
feature_extractor
>
bool
contains_invalid_labeling
(
const
feature_extractor
&
fe
,
const
std
::
vector
<
std
::
vector
<
typename
feature_extractor
::
sample_type
>
>&
x
,
const
std
::
vector
<
std
::
vector
<
unsigned
long
>
>&
y
)
{
if
(
x
.
size
()
!=
y
.
size
())
return
true
;
for
(
unsigned
long
i
=
0
;
i
<
x
.
size
();
++
i
)
{
if
(
contains_invalid_labeling
(
fe
,
x
[
i
],
y
[
i
]))
return
true
;
}
return
false
;
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
template
<
...
...
dlib/svm/sequence_labeler_abstract.h
View file @
1e1d7fc8
...
@@ -164,6 +164,51 @@ namespace dlib
...
@@ -164,6 +164,51 @@ namespace dlib
provides deserialization support
provides deserialization support
!*/
!*/
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
typename
feature_extractor
>
bool
contains_invalid_labeling
(
const
feature_extractor
&
fe
,
const
std
::
vector
<
typename
feature_extractor
::
sample_type
>&
x
,
const
std
::
vector
<
unsigned
long
>&
y
);
/*!
requires
- feature_extractor must be an object that implements an interface compatible
with the example_feature_extractor discussed above.
ensures
- if (x.size() != y.size() ||
fe.reject_labeling() rejects any of the labels in y) then
- returns true
- else
- returns false
!*/
// ----------------------------------------------------------------------------------------
template
<
typename
feature_extractor
>
bool
contains_invalid_labeling
(
const
feature_extractor
&
fe
,
const
std
::
vector
<
std
::
vector
<
typename
feature_extractor
::
sample_type
>
>&
x
,
const
std
::
vector
<
std
::
vector
<
unsigned
long
>
>&
y
);
/*!
requires
- feature_extractor must be an object that implements an interface compatible
with the example_feature_extractor discussed above.
ensures
- if (x.size() != y.size() ||
contains_invalid_labeling(fe,x[i],y[i]) == true for some i ) then
- returns true
- else
- returns false
!*/
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
...
...
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