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
7359ab4b
Commit
7359ab4b
authored
Dec 03, 2011
by
Davis King
Browse files
Setup serialization support for assignment_function objects.
parent
9d81a1ef
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
1 deletion
+44
-1
dlib/svm/assignment_function.h
dlib/svm/assignment_function.h
+44
-1
No files found.
dlib/svm/assignment_function.h
View file @
7359ab4b
...
@@ -90,6 +90,14 @@ namespace dlib
...
@@ -90,6 +90,14 @@ namespace dlib
);
);
}
}
const
feature_extractor
&
get_feature_extractor
(
)
const
{
return
fe
;
}
const
matrix
<
double
,
0
,
1
>&
get_weights
(
)
const
{
return
weights
;
}
bool
forces_assignment
(
)
const
{
return
force_assignment
;
}
result_type
operator
()(
result_type
operator
()(
const
std
::
vector
<
lhs_type
>&
lhs
,
const
std
::
vector
<
lhs_type
>&
lhs
,
...
@@ -156,7 +164,6 @@ namespace dlib
...
@@ -156,7 +164,6 @@ namespace dlib
return
assignment
;
return
assignment
;
}
}
result_type
operator
()
(
result_type
operator
()
(
const
sample_type
&
item
const
sample_type
&
item
)
const
)
const
...
@@ -172,6 +179,42 @@ namespace dlib
...
@@ -172,6 +179,42 @@ namespace dlib
bool
force_assignment
;
bool
force_assignment
;
};
};
// ----------------------------------------------------------------------------------------
template
<
typename
feature_extractor
>
void
serialize
(
const
assignment_function
<
feature_extractor
>&
item
,
std
::
ostream
&
out
)
{
serialize
(
item
.
get_feature_extractor
(),
out
);
serialize
(
item
.
get_weights
(),
out
);
serialize
(
item
.
forces_assignment
(),
out
);
}
// ----------------------------------------------------------------------------------------
template
<
typename
feature_extractor
>
void
deserialize
(
assignment_function
<
feature_extractor
>&
item
,
std
::
istream
&
in
)
{
feature_extractor
fe
;
matrix
<
double
,
0
,
1
>
weights
;
bool
force_assignment
;
deserialize
(
fe
,
in
);
deserialize
(
weights
,
in
);
deserialize
(
force_assignment
,
in
);
item
=
assignment_function
<
feature_extractor
>
(
fe
,
weights
,
force_assignment
);
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
}
}
...
...
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