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
dab7db37
Commit
dab7db37
authored
Dec 04, 2011
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a spec for the structural_svm_assignment_problem and added missing asserts.
parent
9de4e129
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
100 additions
and
1 deletion
+100
-1
structural_svm_assignment_problem.h
dlib/svm/structural_svm_assignment_problem.h
+25
-1
structural_svm_assignment_problem_abstract.h
dlib/svm/structural_svm_assignment_problem_abstract.h
+75
-0
No files found.
dlib/svm/structural_svm_assignment_problem.h
View file @
dab7db37
...
...
@@ -6,7 +6,6 @@
#include "structural_svm_assignment_problem_abstract.h"
#include "../matrix.h"
#include "assignment_function.h"
#include <vector>
#include "structural_svm_problem_threaded.h"
...
...
@@ -46,6 +45,31 @@ namespace dlib
fe
(
fe_
),
force_assignment
(
force_assignment_
)
{
// make sure requires clause is not broken
#ifdef ENABLE_ASSERTS
if
(
force_assignment
)
{
DLIB_ASSERT
(
is_forced_assignment_problem
(
samples
,
labels
),
"
\t
structural_svm_assignment_problem::structural_svm_assignment_problem()"
<<
"
\n\t
invalid inputs were given to this function"
<<
"
\n\t
is_forced_assignment_problem(samples,labels): "
<<
is_forced_assignment_problem
(
samples
,
labels
)
<<
"
\n\t
is_assignment_problem(samples,labels): "
<<
is_assignment_problem
(
samples
,
labels
)
<<
"
\n\t
is_learning_problem(samples,labels): "
<<
is_learning_problem
(
samples
,
labels
)
<<
"
\n\t
this: "
<<
this
);
}
else
{
DLIB_ASSERT
(
is_assignment_problem
(
samples
,
labels
),
"
\t
structural_svm_assignment_problem::structural_svm_assignment_problem()"
<<
"
\n\t
invalid inputs were given to this function"
<<
"
\n\t
is_assignment_problem(samples,labels): "
<<
is_assignment_problem
(
samples
,
labels
)
<<
"
\n\t
is_learning_problem(samples,labels): "
<<
is_learning_problem
(
samples
,
labels
)
<<
"
\n\t
this: "
<<
this
);
}
#endif
}
private
:
...
...
dlib/svm/structural_svm_assignment_problem_abstract.h
View file @
dab7db37
// Copyright (C) 2011 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#undef DLIB_STRUCTURAL_SVM_ASSiGNMENT_PROBLEM_ABSTRACT_H__
#ifdef DLIB_STRUCTURAL_SVM_ASSiGNMENT_PROBLEM_ABSTRACT_H__
#include "../matrix.h"
#include <vector>
#include "structural_svm_problem_threaded_abstract.h"
#include "assignment_function_abstract.h"
// ----------------------------------------------------------------------------------------
namespace
dlib
{
template
<
typename
feature_extractor
>
class
structural_svm_assignment_problem
:
noncopyable
,
public
structural_svm_problem_threaded
<
matrix
<
double
,
0
,
1
>
,
typename
feature_extractor
::
feature_vector_type
>
{
/*!
REQUIREMENTS ON feature_extractor
It must be an object that implements an interface compatible with
the example_feature_extractor defined in dlib/svm/assignment_function_abstract.h.
WHAT THIS OBJECT REPRESENTS
This object is a tool for learning the weight vector needed to use
an assignment_function object. It learns the parameter vector by
formulating the problem as a structural SVM problem.
!*/
public
:
typedef
matrix
<
double
,
0
,
1
>
matrix_type
;
typedef
typename
feature_extractor
::
feature_vector_type
feature_vector_type
;
typedef
typename
feature_extractor
::
lhs_element
lhs_element
;
typedef
typename
feature_extractor
::
rhs_element
rhs_element
;
typedef
std
::
pair
<
std
::
vector
<
lhs_element
>
,
std
::
vector
<
rhs_element
>
>
sample_type
;
typedef
std
::
vector
<
long
>
label_type
;
structural_svm_assignment_problem
(
const
std
::
vector
<
sample_type
>&
samples
,
const
std
::
vector
<
label_type
>&
labels
,
const
feature_extractor
&
fe
,
bool
force_assignment
,
unsigned
long
num_threads
=
2
);
/*!
requires
- is_assignment_problem(samples,labels) == true
- if (force_assignment) then
- is_forced_assignment_problem(samples,labels) == true
ensures
- This object attempts to learn a mapping from the given samples to the
given labels. In particular, it attempts to learn to predict labels[i]
based on samples[i]. Or in other words, this object can be used to learn
a parameter vector, w, such that an assignment_function declared as:
assignment_function<feature_extractor> assigner(fe,w,force_assignment)
results in an assigner object which attempts to compute the following mapping:
labels[i] == labeler(samples[i])
- This object will use num_threads threads during the optimization
procedure. You should set this parameter equal to the number of
available processing cores on your machine.
!*/
};
// ----------------------------------------------------------------------------------------
}
#endif // DLIB_STRUCTURAL_SVM_ASSiGNMENT_PROBLEM_ABSTRACT_H__
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