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
3cffafad
Commit
3cffafad
authored
Dec 02, 2017
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed example to use minimization rather than maximization.
parent
5e8e997b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
global_optimization.py
python_examples/global_optimization.py
+8
-8
No files found.
python_examples/global_optimization.py
View file @
3cffafad
...
...
@@ -3,8 +3,8 @@
#
#
# This is an example illustrating the use of the global optimization routine,
# find_m
ax
_global(), from the dlib C++ Library. This is a tool for finding the
# inputs to a function that result in the function giving its m
ax
imal output.
# find_m
in
_global(), from the dlib C++ Library. This is a tool for finding the
# inputs to a function that result in the function giving its m
in
imal output.
# This is a very useful tool for hyper parameter search when applying machine
# learning methods. There are also many other applications for this kind of
# general derivative free optimization. However, in this example program, we
...
...
@@ -30,17 +30,17 @@ import dlib
from
math
import
sin
,
cos
,
pi
,
exp
,
sqrt
# This is a standard test function for these kinds of optimization problems.
# It has a bunch of local m
axima, with the global max
imum resulting in
# holder_table()==19.2085025679.
# It has a bunch of local m
inima, with the global min
imum resulting in
# holder_table()==
-
19.2085025679.
def
holder_table
(
x0
,
x1
):
return
abs
(
sin
(
x0
)
*
cos
(
x1
)
*
exp
(
abs
(
1
-
sqrt
(
x0
*
x0
+
x1
*
x1
)
/
pi
)))
return
-
abs
(
sin
(
x0
)
*
cos
(
x1
)
*
exp
(
abs
(
1
-
sqrt
(
x0
*
x0
+
x1
*
x1
)
/
pi
)))
# Find the optimal inputs to holder_table(). The print statements that follow
# show that find_m
ax
_global() finds the optimal settings to high precision.
x
,
y
=
dlib
.
find_m
ax
_global
(
holder_table
,
# show that find_m
in
_global() finds the optimal settings to high precision.
x
,
y
=
dlib
.
find_m
in
_global
(
holder_table
,
[
-
10
,
-
10
],
# Lower bound constraints on x0 and x1 respectively
[
10
,
10
],
# Upper bound constraints on x0 and x1 respectively
80
)
# The number of times find_m
ax
_global() will call holder_table()
80
)
# The number of times find_m
in
_global() will call holder_table()
print
(
"optimal inputs: {}"
.
format
(
x
));
print
(
"optimal output: {}"
.
format
(
y
));
...
...
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