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
b7d81290
Commit
b7d81290
authored
May 19, 2012
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added the ability to learn only non-negative weights to the svm_c_linear_trainer.
parent
2f562b03
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
1 deletion
+44
-1
svm_c_linear_trainer.h
dlib/svm/svm_c_linear_trainer.h
+21
-1
svm_c_linear_trainer_abstract.h
dlib/svm/svm_c_linear_trainer_abstract.h
+23
-0
No files found.
dlib/svm/svm_c_linear_trainer.h
View file @
b7d81290
...
...
@@ -352,6 +352,7 @@ namespace dlib
verbose
=
false
;
eps
=
0
.
001
;
max_iterations
=
10000
;
learn_nonnegative_weights
=
false
;
}
explicit
svm_c_linear_trainer
(
...
...
@@ -371,6 +372,7 @@ namespace dlib
verbose
=
false
;
eps
=
0
.
001
;
max_iterations
=
10000
;
learn_nonnegative_weights
=
false
;
}
void
set_epsilon
(
...
...
@@ -432,6 +434,16 @@ namespace dlib
return
kernel_type
();
}
bool
learns_nonnegative_weights
(
)
const
{
return
learn_nonnegative_weights
;
}
void
set_learns_nonnegative_weights
(
bool
value
)
{
learn_nonnegative_weights
=
value
;
}
void
set_c
(
scalar_type
C
)
...
...
@@ -544,9 +556,16 @@ namespace dlib
typedef
matrix
<
scalar_type
,
0
,
1
>
w_type
;
w_type
w
;
unsigned
long
num_nonnegative
=
0
;
if
(
learn_nonnegative_weights
)
{
num_nonnegative
=
max_index_plus_one
(
x
);
}
svm_objective
=
solver
(
make_oca_problem_c_svm
<
w_type
>
(
Cpos
,
Cneg
,
x
,
y
,
verbose
,
eps
,
max_iterations
),
w
);
w
,
num_nonnegative
);
// put the solution into a decision function and then return it
decision_function
<
kernel_type
>
df
;
...
...
@@ -570,6 +589,7 @@ namespace dlib
scalar_type
eps
;
bool
verbose
;
unsigned
long
max_iterations
;
bool
learn_nonnegative_weights
;
};
// ----------------------------------------------------------------------------------------
...
...
dlib/svm/svm_c_linear_trainer_abstract.h
View file @
b7d81290
...
...
@@ -52,6 +52,7 @@ namespace dlib
- #get_epsilon() == 0.001
- this object will not be verbose unless be_verbose() is called
- #get_max_iterations() == 10000
- #learns_nonnegative_weights() == false
!*/
explicit
svm_c_linear_trainer
(
...
...
@@ -69,6 +70,7 @@ namespace dlib
- #get_epsilon() == 0.001
- this object will not be verbose unless be_verbose() is called
- #get_max_iterations() == 10000
- #learns_nonnegative_weights() == false
!*/
void
set_epsilon
(
...
...
@@ -145,6 +147,27 @@ namespace dlib
returns kernel_type()
!*/
bool
learns_nonnegative_weights
(
)
const
;
/*!
ensures
- The output of training is a weight vector and a bias value. These
two things define the resulting decision function. That is, the
decision function simply takes the dot product between the learned
weight vector and a test sample, then subtracts the bias value.
Therefore, if learns_nonnegative_weights() == true then the resulting
learned weight vector will always have non-negative entries. The
bias value may still be negative though.
!*/
void
set_learns_nonnegative_weights
(
bool
value
);
/*!
ensures
- #learns_nonnegative_weights() == value
!*/
void
set_c
(
scalar_type
C
);
...
...
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