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
f02d09da
Commit
f02d09da
authored
May 12, 2013
by
Davis King
Browse files
Added is_sequence_segmentation_problem()
parent
4a527aa8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
0 deletions
+76
-0
dlib/svm/svm.h
dlib/svm/svm.h
+43
-0
dlib/svm/svm_abstract.h
dlib/svm/svm_abstract.h
+33
-0
No files found.
dlib/svm/svm.h
View file @
f02d09da
...
...
@@ -198,6 +198,49 @@ namespace dlib
return
false
;
}
// ----------------------------------------------------------------------------------------
template
<
typename
sequence_type
>
bool
is_sequence_segmentation_problem
(
const
std
::
vector
<
sequence_type
>&
samples
,
const
std
::
vector
<
std
::
vector
<
std
::
pair
<
unsigned
long
,
unsigned
long
>
>
>&
segments
)
{
if
(
is_learning_problem
(
samples
,
segments
))
{
for
(
unsigned
long
i
=
0
;
i
<
samples
.
size
();
++
i
)
{
// Make sure the segments are inside samples[i] and don't overlap with each
// other.
std
::
vector
<
bool
>
hits
(
samples
[
i
].
size
(),
false
);
for
(
unsigned
long
j
=
0
;
j
<
segments
[
i
].
size
();
++
j
)
{
const
unsigned
long
begin
=
segments
[
i
][
j
].
first
;
const
unsigned
long
end
=
segments
[
i
][
j
].
second
;
// if the segment is outside the sequence
if
(
end
>
samples
[
i
].
size
())
return
false
;
if
(
begin
>
end
)
return
false
;
// check for overlap
for
(
unsigned
long
k
=
begin
;
k
<
end
;
++
k
)
{
if
(
hits
[
k
])
return
false
;
hits
[
k
]
=
true
;
}
}
}
return
true
;
}
return
false
;
}
// ----------------------------------------------------------------------------------------
template
<
...
...
dlib/svm/svm_abstract.h
View file @
f02d09da
...
...
@@ -40,6 +40,8 @@ namespace dlib
- x.size() > 0
!*/
// ----------------------------------------------------------------------------------------
template
<
typename
T
,
typename
U
...
...
@@ -62,6 +64,8 @@ namespace dlib
- x_labels(i) == -1 or +1
!*/
// ----------------------------------------------------------------------------------------
template
<
typename
sequence_type
>
...
...
@@ -79,6 +83,33 @@ namespace dlib
its corresponding sample sequence)
!*/
// ----------------------------------------------------------------------------------------
template
<
typename
sequence_type
>
bool
is_sequence_segmentation_problem
(
const
std
::
vector
<
sequence_type
>&
samples
,
const
std
::
vector
<
std
::
vector
<
std
::
pair
<
unsigned
long
,
unsigned
long
>
>
>&
segments
);
/*!
ensures
- returns true if all of the following are true and false otherwise:
- is_learning_problem(samples, segments) == true
- for all valid i:
- for all valid j:
- We interpret segments[i][j] as defining a half open range
starting with segments[i][j].first and ending just before
segments[i][j].second.
- segments[i][j].first <= segments[i][j].second
- segments[i][j].second <= samples[i].size()
(i.e. Each segment must be contained within its associated sequence)
- segments[i][j] does not overlap with any of the other ranges in
segments[i].
!*/
// ----------------------------------------------------------------------------------------
template
<
typename
lhs_type
,
typename
rhs_type
...
...
@@ -106,6 +137,8 @@ namespace dlib
in samples[i].second.
!*/
// ----------------------------------------------------------------------------------------
template
<
typename
lhs_type
,
typename
rhs_type
...
...
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