Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
BayesianOptimization
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
shamith2
BayesianOptimization
Commits
d928f909
Commit
d928f909
authored
5 years ago
by
shamith2
Browse files
Options
Downloads
Patches
Plain Diff
Update runBO.py
parent
96cd7d6e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fmfnBO/runBO.py
+56
-56
56 additions, 56 deletions
fmfnBO/runBO.py
with
56 additions
and
56 deletions
fmfnBO/runBO.py
+
56
−
56
View file @
d928f909
import
os
import
sys
import
argparse
import
pathlib
from
bayes_opt
import
BayesianOptimization
,
Events
,
JSONLogger
# current working directory
cwd
=
pathlib
.
Path
(
__file__
).
parent
.
absolute
()
parent
=
os
.
path
.
split
(
cwd
)[
0
]
if
str
(
parent
)
not
in
sys
.
path
:
sys
.
path
.
append
(
parent
)
from
target
import
*
def
fmfnBO
(
n_eval
,
ndim
,
func
=
None
):
assert
func
is
not
None
logs
=
os
.
path
.
join
(
cwd
,
'
logs/
'
)
plots
=
os
.
path
.
join
(
cwd
,
'
plots/
'
)
if
not
os
.
path
.
isdir
(
logs
):
os
.
mkdir
(
logs
)
if
not
os
.
path
.
isdir
(
plots
):
os
.
mkdir
(
plots
)
log_name
=
os
.
path
.
join
(
logs
+
str
(
func
)
+
"
.json
"
)
plot_name
=
os
.
path
.
join
(
plots
+
str
(
func
)
+
"
.json
"
)
optimizer
=
BayesianOptimization
(
func
,
func
.
pbounds
,
random_state
=
1
)
logger
=
JSONLogger
(
log_name
)
optimizer
.
subscribe
(
Events
.
OPTIMIZATION_STEP
,
logger
)
steps
=
n_eval
optimizer
.
maximize
(
init_points
=
2
,
n_iter
=
0
,
acq
=
'
ei
'
,
kappa
=
5
)
optimizer
.
maximize
(
init_points
=
0
,
n_iter
=
steps
,
acq
=
'
ei
'
,
kappa
=
5
)
print
(
"
Output Files:
"
)
return
(
func
,
log_name
,
plot_name
)
if
__name__
==
'
__main__
'
:
parser
=
argparse
.
ArgumentParser
(
description
=
'
FmFn Bayesian Optimization runner
'
)
parser
.
add_argument
(
'
-e
'
,
'
--n_eval
'
,
dest
=
'
n_eval
'
,
type
=
int
,
default
=
1
)
parser
.
add_argument
(
'
-d
'
,
'
--dim
'
,
dest
=
'
ndim
'
,
type
=
int
,
default
=
1
)
parser
.
add_argument
(
'
-f
'
,
'
--func
'
,
dest
=
'
func_name
'
)
args
=
parser
.
parse_args
()
fmfn_args
=
vars
(
args
)
if
args
.
func_name
is
not
None
:
exec
(
'
func=
'
+
'
fmfn_
'
+
args
.
func_name
)
fmfn_args
[
'
func
'
]
=
func
del
fmfn_args
[
'
func_name
'
]
fmfn_files
=
fmfnBO
(
**
fmfn_args
)
import
os
import
sys
import
argparse
import
pathlib
from
bayes_opt
import
BayesianOptimization
,
Events
,
JSONLogger
# current working directory
cwd
=
pathlib
.
Path
(
__file__
).
parent
.
absolute
()
parent
=
os
.
path
.
split
(
cwd
)[
0
]
if
str
(
parent
)
not
in
sys
.
path
:
sys
.
path
.
append
(
parent
)
from
target
import
*
def
fmfnBO
(
n_eval
,
ndim
,
func
=
None
):
assert
func
is
not
None
logs
=
os
.
path
.
join
(
cwd
,
'
logs/
'
)
plots
=
os
.
path
.
join
(
cwd
,
'
plots/
'
)
if
not
os
.
path
.
isdir
(
logs
):
os
.
mkdir
(
logs
)
if
not
os
.
path
.
isdir
(
plots
):
os
.
mkdir
(
plots
)
log_name
=
os
.
path
.
join
(
logs
+
str
(
func
)
+
"
.json
"
)
plot_name
=
os
.
path
.
join
(
plots
+
str
(
func
)
+
"
.json
"
)
optimizer
=
BayesianOptimization
(
func
,
func
.
pbounds
,
random_state
=
1
)
logger
=
JSONLogger
(
log_name
)
optimizer
.
subscribe
(
Events
.
OPTIMIZATION_STEP
,
logger
)
steps
=
n_eval
optimizer
.
maximize
(
init_points
=
2
,
n_iter
=
0
,
acq
=
'
ei
'
,
kappa
=
5
)
optimizer
.
maximize
(
init_points
=
0
,
n_iter
=
steps
,
acq
=
'
ei
'
,
kappa
=
5
)
print
(
"
Output Files:
"
)
return
(
func
,
log_name
,
plot_name
)
if
__name__
==
'
__main__
'
:
parser
=
argparse
.
ArgumentParser
(
description
=
'
FmFn Bayesian Optimization runner
'
)
parser
.
add_argument
(
'
-e
'
,
'
--n_eval
'
,
dest
=
'
n_eval
'
,
type
=
int
,
default
=
1
)
parser
.
add_argument
(
'
-d
'
,
'
--dim
'
,
dest
=
'
ndim
'
,
type
=
int
,
default
=
1
)
parser
.
add_argument
(
'
-f
'
,
'
--func
'
,
dest
=
'
func_name
'
)
args
=
parser
.
parse_args
()
fmfn_args
=
vars
(
args
)
if
args
.
func_name
is
not
None
:
exec
(
'
func=
'
+
'
fmfn_
'
+
'
neg_
'
+
args
.
func_name
)
fmfn_args
[
'
func
'
]
=
func
del
fmfn_args
[
'
func_name
'
]
fmfn_files
=
fmfnBO
(
**
fmfn_args
)
print
(
fmfn_files
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment