Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
baseLess
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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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
Lannoy, Carlos de
baseLess
Commits
c02c5630
Commit
c02c5630
authored
3 years ago
by
Noordijk, Ben
Browse files
Options
Downloads
Patches
Plain Diff
Bugfixed optimize_hyperparams.py
parent
cf2c79f1
No related branches found
No related tags found
1 merge request
!3
Added data preparation, hyperparameter optimisation, benchmarking code and k-mer library visualisation
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
hyperparameter_search/optimize_hyperparams.py
+23
-24
23 additions, 24 deletions
hyperparameter_search/optimize_hyperparams.py
with
23 additions
and
24 deletions
hyperparameter_search/optimize_hyperparams.py
+
23
−
24
View file @
c02c5630
...
@@ -69,7 +69,10 @@ def main(args):
...
@@ -69,7 +69,10 @@ def main(args):
ranges_dict
=
yaml
.
load
(
fh
,
yaml
.
FullLoader
)
ranges_dict
=
yaml
.
load
(
fh
,
yaml
.
FullLoader
)
# Generate dbs
# Generate dbs
with
open
(
args
.
kmer_list
,
'
r
'
)
as
fh
:
kmer_list
=
[
k
.
strip
()
for
k
in
fh
.
readlines
()
if
len
(
k
.
strip
())]
with
open
(
args
.
kmer_list
,
'
r
'
)
as
fh
:
kmer_list
=
[
k
.
strip
()
for
k
in
fh
.
readlines
()
if
len
(
k
.
strip
())]
kmer_list
=
kmer_list
[:
2
]
db_dir
=
parse_output_path
(
f
'
{
args
.
out_dir
}
dbs/
'
)
db_dir
=
parse_output_path
(
f
'
{
args
.
out_dir
}
dbs/
'
)
logs_dir
=
parse_output_path
(
f
'
{
args
.
out_dir
}
logs/
'
)
logs_dir
=
parse_output_path
(
f
'
{
args
.
out_dir
}
logs/
'
)
...
@@ -108,30 +111,26 @@ def main(args):
...
@@ -108,30 +111,26 @@ def main(args):
"
--directoryperdb
"
,
"
--fork
"
,
"
--journal
"
,
"
--directoryperdb
"
,
"
--fork
"
,
"
--journal
"
,
"
--logpath
"
,
f
"
{
args
.
out_dir
}
mongodb_log.log
"
])
"
--logpath
"
,
f
"
{
args
.
out_dir
}
mongodb_log.log
"
])
try
:
# start worker processses
worker_cmd_list
=
[
"
hyperopt-mongo-worker
"
,
"
--mongo=localhost:1234/db
"
]
worker_list
=
[
subprocess
.
Popen
(
worker_cmd_list
,
stdout
=
open
(
os
.
devnull
,
'
wb
'
),
stderr
=
open
(
os
.
devnull
,
'
wb
'
))
for
_
in
range
(
args
.
hyperopt_parallel_jobs
)]
# minimize objective
trials
=
MongoTrials
(
'
mongo://localhost:1234/db/jobs
'
)
# trials = hp.Trials()
out_param_dict
=
hp
.
fmin
(
fmin_objective
,
space
=
space
,
algo
=
hp
.
tpe
.
suggest
,
trials
=
trials
,
max_evals
=
args
.
hyperopt_iters
,
max_queue_len
=
args
.
hyperopt_parallel_jobs
)
for
worker
in
worker_list
:
worker
.
terminate
()
subprocess
.
run
([
'
mongod
'
,
'
--shutdown
'
,
'
--dbpath
'
,
mongodb_pth
])
except
Exception
as
e
:
print
(
f
'
Had to exit:
{
e
}
'
)
subprocess
.
run
([
'
mongod
'
,
'
--shutdown
'
,
'
--dbpath
'
,
mongodb_pth
])
# todo can't this be done more elegantly?
# start worker processses
worker_cmd_list
=
[
"
hyperopt-mongo-worker
"
,
"
--mongo=localhost:1234/db
"
]
worker_list
=
[
subprocess
.
Popen
(
worker_cmd_list
,
stdout
=
open
(
os
.
devnull
,
'
wb
'
),
stderr
=
open
(
os
.
devnull
,
'
wb
'
))
for
_
in
range
(
args
.
hyperopt_parallel_jobs
)]
# minimize objective
trials
=
MongoTrials
(
'
mongo://localhost:1234/db/jobs
'
,
exp_key
=
'
test_1
'
)
out_param_dict
=
hp
.
fmin
(
fmin_objective
,
space
=
space
,
algo
=
hp
.
tpe
.
suggest
,
trials
=
trials
,
max_evals
=
args
.
hyperopt_iters
)
for
worker
in
worker_list
:
worker
.
terminate
()
subprocess
.
run
([
'
mongod
'
,
'
--shutdown
'
,
'
--dbpath
'
,
mongodb_pth
])
print
(
out_param_dict
)
for
p
in
out_param_dict
:
for
p
in
out_param_dict
:
if
ranges_dict
[
'
variable
'
][
p
][
'
type
'
]
==
'
int
'
:
out_param_dict
[
p
]
=
int
(
out_param_dict
[
p
])
if
ranges_dict
[
'
variable
'
][
p
][
'
type
'
]
==
'
int
'
:
out_param_dict
[
p
]
=
int
(
out_param_dict
[
p
])
for
p
in
ranges_dict
[
'
nonvariable
'
]:
out_param_dict
[
p
]
=
ranges_dict
[
'
nonvariable
'
][
p
]
for
p
in
ranges_dict
[
'
nonvariable
'
]:
out_param_dict
[
p
]
=
ranges_dict
[
'
nonvariable
'
][
p
]
...
...
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