Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
1e1d7fc8
Commit
1e1d7fc8
authored
Dec 09, 2011
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added the contains_invalid_labeling() routine.
parent
ea26c37b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
114 additions
and
0 deletions
+114
-0
sequence_labeler.h
dlib/svm/sequence_labeler.h
+69
-0
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
}
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
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
<
...
...
dlib/svm/sequence_labeler_abstract.h
View file @
1e1d7fc8
...
...
@@ -164,6 +164,51 @@ namespace dlib
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