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
128cc0cb
Commit
128cc0cb
authored
Sep 28, 2011
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a parameter to control the maximum number of iterations for the
two OCA based svm optimizers.
parent
507fc315
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
77 additions
and
5 deletions
+77
-5
svm_c_ekm_trainer.h
dlib/svm/svm_c_ekm_trainer.h
+13
-0
svm_c_ekm_trainer_abstract.h
dlib/svm/svm_c_ekm_trainer_abstract.h
+18
-0
svm_c_linear_trainer.h
dlib/svm/svm_c_linear_trainer.h
+28
-5
svm_c_linear_trainer_abstract.h
dlib/svm/svm_c_linear_trainer_abstract.h
+18
-0
No files found.
dlib/svm/svm_c_ekm_trainer.h
View file @
128cc0cb
...
@@ -82,6 +82,19 @@ namespace dlib
...
@@ -82,6 +82,19 @@ namespace dlib
return
ocas
.
get_epsilon
();
return
ocas
.
get_epsilon
();
}
}
void
set_max_iterations
(
unsigned
long
max_iter
)
{
ocas
.
set_max_iterations
(
max_iter
);
}
unsigned
long
get_max_iterations
(
)
{
return
ocas
.
get_max_iterations
();
}
void
be_verbose
(
void
be_verbose
(
)
)
{
{
...
...
dlib/svm/svm_c_ekm_trainer_abstract.h
View file @
128cc0cb
...
@@ -49,6 +49,7 @@ namespace dlib
...
@@ -49,6 +49,7 @@ namespace dlib
- #get_basis_size_increment() == 50
- #get_basis_size_increment() == 50
- #get_max_basis_size() == 300
- #get_max_basis_size() == 300
- this object will not be verbose unless be_verbose() is called
- this object will not be verbose unless be_verbose() is called
- #get_max_iterations() == 10000
!*/
!*/
explicit
svm_c_ekm_trainer
(
explicit
svm_c_ekm_trainer
(
...
@@ -69,6 +70,7 @@ namespace dlib
...
@@ -69,6 +70,7 @@ namespace dlib
- #get_basis_size_increment() == 50
- #get_basis_size_increment() == 50
- #get_max_basis_size() == 300
- #get_max_basis_size() == 300
- this object will not be verbose unless be_verbose() is called
- this object will not be verbose unless be_verbose() is called
- #get_max_iterations() == 10000
!*/
!*/
void
set_epsilon
(
void
set_epsilon
(
...
@@ -90,6 +92,22 @@ namespace dlib
...
@@ -90,6 +92,22 @@ namespace dlib
to execute.
to execute.
!*/
!*/
void
set_max_iterations
(
unsigned
long
max_iter
);
/*!
ensures
- #get_max_iterations() == max_iter
!*/
unsigned
long
get_max_iterations
(
);
/*!
ensures
- returns the maximum number of iterations the SVM optimizer is allowed to
run before it is required to stop and return a result.
!*/
void
be_verbose
(
void
be_verbose
(
);
);
/*!
/*!
...
...
dlib/svm/svm_c_linear_trainer.h
View file @
128cc0cb
...
@@ -43,14 +43,16 @@ namespace dlib
...
@@ -43,14 +43,16 @@ namespace dlib
const
in_sample_vector_type
&
samples_
,
const
in_sample_vector_type
&
samples_
,
const
in_scalar_vector_type
&
labels_
,
const
in_scalar_vector_type
&
labels_
,
const
bool
be_verbose_
,
const
bool
be_verbose_
,
const
scalar_type
eps_
const
scalar_type
eps_
,
const
unsigned
long
max_iter
)
:
)
:
samples
(
samples_
),
samples
(
samples_
),
labels
(
labels_
),
labels
(
labels_
),
Cpos
(
C_pos
),
Cpos
(
C_pos
),
Cneg
(
C_neg
),
Cneg
(
C_neg
),
be_verbose
(
be_verbose_
),
be_verbose
(
be_verbose_
),
eps
(
eps_
)
eps
(
eps_
),
max_iterations
(
max_iter
)
{
{
dot_prods
.
resize
(
samples
.
size
());
dot_prods
.
resize
(
samples
.
size
());
is_first_call
=
true
;
is_first_call
=
true
;
...
@@ -88,6 +90,9 @@ namespace dlib
...
@@ -88,6 +90,9 @@ namespace dlib
cout
<<
endl
;
cout
<<
endl
;
}
}
if
(
num_iterations
>=
max_iterations
)
return
true
;
if
(
current_objective_value
==
0
)
if
(
current_objective_value
==
0
)
return
true
;
return
true
;
...
@@ -292,6 +297,7 @@ namespace dlib
...
@@ -292,6 +297,7 @@ namespace dlib
const
bool
be_verbose
;
const
bool
be_verbose
;
const
scalar_type
eps
;
const
scalar_type
eps
;
const
unsigned
long
max_iterations
;
};
};
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
...
@@ -308,10 +314,12 @@ namespace dlib
...
@@ -308,10 +314,12 @@ namespace dlib
const
in_sample_vector_type
&
samples
,
const
in_sample_vector_type
&
samples
,
const
in_scalar_vector_type
&
labels
,
const
in_scalar_vector_type
&
labels
,
const
bool
be_verbose
,
const
bool
be_verbose
,
const
scalar_type
eps
const
scalar_type
eps
,
const
unsigned
char
max_iterations
)
)
{
{
return
oca_problem_c_svm
<
matrix_type
,
in_sample_vector_type
,
in_scalar_vector_type
>
(
C_pos
,
C_neg
,
samples
,
labels
,
be_verbose
,
eps
);
return
oca_problem_c_svm
<
matrix_type
,
in_sample_vector_type
,
in_scalar_vector_type
>
(
C_pos
,
C_neg
,
samples
,
labels
,
be_verbose
,
eps
,
max_iterations
);
}
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
...
@@ -342,6 +350,7 @@ namespace dlib
...
@@ -342,6 +350,7 @@ namespace dlib
Cneg
=
1
;
Cneg
=
1
;
verbose
=
false
;
verbose
=
false
;
eps
=
0
.
001
;
eps
=
0
.
001
;
max_iterations
=
10000
;
}
}
explicit
svm_c_linear_trainer
(
explicit
svm_c_linear_trainer
(
...
@@ -358,6 +367,9 @@ namespace dlib
...
@@ -358,6 +367,9 @@ namespace dlib
Cpos
=
C
;
Cpos
=
C
;
Cneg
=
C
;
Cneg
=
C
;
verbose
=
false
;
eps
=
0
.
001
;
max_iterations
=
10000
;
}
}
void
set_epsilon
(
void
set_epsilon
(
...
@@ -378,6 +390,16 @@ namespace dlib
...
@@ -378,6 +390,16 @@ namespace dlib
const
scalar_type
get_epsilon
(
const
scalar_type
get_epsilon
(
)
const
{
return
eps
;
}
)
const
{
return
eps
;
}
unsigned
long
get_max_iterations
(
)
const
{
return
max_iterations
;
}
void
set_max_iterations
(
unsigned
long
max_iter
)
{
max_iterations
=
max_iter
;
}
void
be_verbose
(
void
be_verbose
(
)
)
{
{
...
@@ -522,7 +544,7 @@ namespace dlib
...
@@ -522,7 +544,7 @@ namespace dlib
w_type
w
;
w_type
w
;
svm_objective
=
solver
(
svm_objective
=
solver
(
make_oca_problem_c_svm
<
w_type
>
(
Cpos
,
Cneg
,
x
,
y
,
verbose
,
eps
),
make_oca_problem_c_svm
<
w_type
>
(
Cpos
,
Cneg
,
x
,
y
,
verbose
,
eps
,
max_iterations
),
w
);
w
);
// put the solution into a decision function and then return it
// put the solution into a decision function and then return it
...
@@ -546,6 +568,7 @@ namespace dlib
...
@@ -546,6 +568,7 @@ namespace dlib
oca
solver
;
oca
solver
;
scalar_type
eps
;
scalar_type
eps
;
bool
verbose
;
bool
verbose
;
unsigned
long
max_iterations
;
};
};
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
...
...
dlib/svm/svm_c_linear_trainer_abstract.h
View file @
128cc0cb
...
@@ -51,6 +51,7 @@ namespace dlib
...
@@ -51,6 +51,7 @@ namespace dlib
- #get_c_class2() == 1
- #get_c_class2() == 1
- #get_epsilon() == 0.001
- #get_epsilon() == 0.001
- this object will not be verbose unless be_verbose() is called
- this object will not be verbose unless be_verbose() is called
- #get_max_iterations() == 10000
!*/
!*/
explicit
svm_c_linear_trainer
(
explicit
svm_c_linear_trainer
(
...
@@ -67,6 +68,7 @@ namespace dlib
...
@@ -67,6 +68,7 @@ namespace dlib
- #get_c_class2() == C
- #get_c_class2() == C
- #get_epsilon() == 0.001
- #get_epsilon() == 0.001
- this object will not be verbose unless be_verbose() is called
- this object will not be verbose unless be_verbose() is called
- #get_max_iterations() == 10000
!*/
!*/
void
set_epsilon
(
void
set_epsilon
(
...
@@ -88,6 +90,22 @@ namespace dlib
...
@@ -88,6 +90,22 @@ namespace dlib
to execute.
to execute.
!*/
!*/
void
set_max_iterations
(
unsigned
long
max_iter
);
/*!
ensures
- #get_max_iterations() == max_iter
!*/
unsigned
long
get_max_iterations
(
);
/*!
ensures
- returns the maximum number of iterations the SVM optimizer is allowed to
run before it is required to stop and return a result.
!*/
void
be_verbose
(
void
be_verbose
(
);
);
/*!
/*!
...
...
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