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
97f82b1e
Commit
97f82b1e
authored
Jun 08, 2013
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made decision functions and segmenter objects callable like normal functions.
parent
35a25775
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
7 deletions
+7
-7
sequence_segmenter.py
python_examples/sequence_segmenter.py
+3
-3
decision_functions.cpp
tools/python/src/decision_functions.cpp
+2
-2
sequence_segmenter.cpp
tools/python/src/sequence_segmenter.cpp
+2
-2
No files found.
python_examples/sequence_segmenter.py
View file @
97f82b1e
...
...
@@ -156,15 +156,15 @@ model = dlib.train_sequence_segmenter(training_sequences, segments, params)
# which are predicted to contain names. If you run this example program you will see that
# it gets them all correct.
for
i
in
range
(
len
(
sentences
)):
print_segment
(
sentences
[
i
],
model
.
segment_sequence
(
training_sequences
[
i
]))
print_segment
(
sentences
[
i
],
model
(
training_sequences
[
i
]))
# Lets also try segmenting a new sentence. This will print out "Bob Bucket". Note that we
# need to remember to use the same vector representation as we used during training.
test_sentence
=
"There once was a man from Nantucket whose name rhymed with Bob Bucket"
if
use_sparse_vects
:
print_segment
(
test_sentence
,
model
.
segment_sequence
(
sentence_to_sparse_vectors
(
test_sentence
)))
print_segment
(
test_sentence
,
model
(
sentence_to_sparse_vectors
(
test_sentence
)))
else
:
print_segment
(
test_sentence
,
model
.
segment_sequence
(
sentence_to_vectors
(
test_sentence
)))
print_segment
(
test_sentence
,
model
(
sentence_to_vectors
(
test_sentence
)))
# We can also measure the accuracy of a model relative to some labeled data. This
# statement prints the precision, recall, and F1-score of the model relative to the data in
...
...
tools/python/src/decision_functions.cpp
View file @
97f82b1e
...
...
@@ -42,7 +42,7 @@ void add_df (
{
typedef
decision_function
<
kernel_type
>
df_type
;
class_
<
df_type
>
(
name
.
c_str
())
.
def
(
"
predict
"
,
&
predict
<
df_type
>
)
.
def
(
"
__call__
"
,
&
predict
<
df_type
>
)
.
def_pickle
(
serialize_pickle
<
df_type
>
());
}
...
...
@@ -94,7 +94,7 @@ void add_linear_df (
{
typedef
decision_function
<
kernel_type
>
df_type
;
class_
<
df_type
>
(
name
.
c_str
())
.
def
(
"
predict
"
,
predict
<
df_type
>
)
.
def
(
"
__call__
"
,
predict
<
df_type
>
)
.
add_property
(
"weights"
,
&
get_weights
<
df_type
>
)
.
add_property
(
"bias"
,
get_bias
<
df_type
>
,
set_bias
<
df_type
>
)
.
def_pickle
(
serialize_pickle
<
df_type
>
());
...
...
tools/python/src/sequence_segmenter.cpp
View file @
97f82b1e
...
...
@@ -795,8 +795,8 @@ train_sequence_segmenter() and cross_validate_sequence_segmenter() routines. "
.
def_pickle
(
serialize_pickle
<
segmenter_params
>
());
class_
<
segmenter_type
>
(
"segmenter_type"
)
.
def
(
"
segment_sequence
"
,
&
segmenter_type
::
segment_sequence_dense
)
.
def
(
"
segment_sequence
"
,
&
segmenter_type
::
segment_sequence_sparse
)
.
def
(
"
__call__
"
,
&
segmenter_type
::
segment_sequence_dense
)
.
def
(
"
__call__
"
,
&
segmenter_type
::
segment_sequence_sparse
)
.
def_readonly
(
"weights"
,
&
segmenter_type
::
get_weights
)
.
def_pickle
(
serialize_pickle
<
segmenter_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