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
3a5f99f4
Commit
3a5f99f4
authored
May 06, 2012
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated the interface to the structural_graph_labeling_trainer so the user
can set the per class loss to whatever they want.
parent
42c123f2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
84 additions
and
0 deletions
+84
-0
structural_graph_labeling_trainer.h
dlib/svm/structural_graph_labeling_trainer.h
+42
-0
structural_graph_labeling_trainer_abstract.h
dlib/svm/structural_graph_labeling_trainer_abstract.h
+42
-0
No files found.
dlib/svm/structural_graph_labeling_trainer.h
View file @
3a5f99f4
...
...
@@ -32,6 +32,8 @@ namespace dlib
eps
=
0
.
1
;
num_threads
=
2
;
max_cache_size
=
40
;
loss_pos
=
1
.
0
;
loss_neg
=
1
.
0
;
}
void
set_num_threads
(
...
...
@@ -124,6 +126,42 @@ namespace dlib
return
C
;
}
void
set_loss_on_positive_class
(
double
loss
)
{
// make sure requires clause is not broken
DLIB_ASSERT
(
loss
>=
0
,
"
\t
structural_graph_labeling_trainer::set_loss_on_positive_class()"
<<
"
\n\t
Invalid inputs were given to this function."
<<
"
\n\t
loss: "
<<
loss
<<
"
\n\t
this: "
<<
this
);
loss_pos
=
loss
;
}
void
set_loss_on_negative_class
(
double
loss
)
{
// make sure requires clause is not broken
DLIB_ASSERT
(
loss
>=
0
,
"
\t
structural_graph_labeling_trainer::set_loss_on_negative_class()"
<<
"
\n\t
Invalid inputs were given to this function."
<<
"
\n\t
loss: "
<<
loss
<<
"
\n\t
this: "
<<
this
);
loss_neg
=
loss
;
}
double
get_loss_on_negative_class
(
)
const
{
return
loss_neg
;
}
double
get_loss_on_positive_class
(
)
const
{
return
loss_pos
;
}
template
<
typename
graph_type
>
...
...
@@ -150,6 +188,8 @@ namespace dlib
prob
.
set_c
(
C
);
prob
.
set_epsilon
(
eps
);
prob
.
set_max_cache_size
(
max_cache_size
);
prob
.
set_loss_on_positive_class
(
loss_pos
);
prob
.
set_loss_on_negative_class
(
loss_neg
);
matrix
<
double
,
0
,
1
>
w
;
solver
(
prob
,
w
,
prob
.
get_num_edge_weights
());
...
...
@@ -203,6 +243,8 @@ namespace dlib
bool
verbose
;
unsigned
long
num_threads
;
unsigned
long
max_cache_size
;
double
loss_pos
;
double
loss_neg
;
};
// ----------------------------------------------------------------------------------------
...
...
dlib/svm/structural_graph_labeling_trainer_abstract.h
View file @
3a5f99f4
...
...
@@ -48,6 +48,8 @@ namespace dlib
- #get_epsilon() == 0.1
- #get_num_threads() == 2
- #get_max_cache_size() == 40
- #get_loss_on_positive_class() == 1.0
- #get_loss_on_negative_class() == 1.0
!*/
void
set_num_threads
(
...
...
@@ -159,6 +161,46 @@ namespace dlib
better generalization.
!*/
void
set_loss_on_positive_class
(
double
loss
);
/*!
requires
- loss >= 0
ensures
- #get_loss_on_positive_class() == loss
!*/
void
set_loss_on_negative_class
(
double
loss
);
/*!
requires
- loss >= 0
ensures
- #get_loss_on_negative_class() == loss
!*/
double
get_loss_on_positive_class
(
)
const
;
/*!
ensures
- returns the loss incurred when a graph node which is supposed to have
a label of true gets misclassified. This value controls how much we care
about correctly classifying nodes which should be labeled as true. Larger
loss values indicate that we care more strongly than smaller values.
!*/
double
get_loss_on_negative_class
(
)
const
;
/*!
ensures
- returns the loss incurred when a graph node which is supposed to have
a label of false gets misclassified. This value controls how much we care
about correctly classifying nodes which should be labeled as false. Larger
loss values indicate that we care more strongly than smaller values.
!*/
template
<
typename
graph_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