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
728b3d1a
Commit
728b3d1a
authored
3 years ago
by
Noordijk, Ben
Browse files
Options
Downloads
Patches
Plain Diff
Hyperparams modifies path more explicitly and prints parameter dict after optimisation is finished
parent
6b564885
No related branches found
Branches containing commit
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
+8
-4
8 additions, 4 deletions
hyperparameter_search/optimize_hyperparams.py
with
8 additions
and
4 deletions
hyperparameter_search/optimize_hyperparams.py
+
8
−
4
View file @
728b3d1a
...
...
@@ -9,7 +9,6 @@ from train_nn import train
from
datetime
import
datetime
from
jinja2
import
Template
from
snakemake
import
snakemake
sys
.
path
.
append
(
f
'
{
Path
(
__file__
).
resolve
()
}
/..
'
)
from
helper_functions
import
parse_output_path
from
pathlib
import
Path
...
...
@@ -21,6 +20,7 @@ integer_hps = ['layer_size', 'num_layers', 'filter_width', 'batch_size',
__location__
=
os
.
path
.
dirname
(
Path
(
__file__
).
resolve
())
baseless_location
=
Path
(
__file__
).
parents
[
1
].
resolve
()
sys
.
path
.
append
(
str
(
baseless_location
))
def
generate_header
(
loss
):
out_txt
=
f
"""
...
...
@@ -64,7 +64,8 @@ def main(args):
ranges_dict
=
yaml
.
load
(
fh
,
yaml
.
FullLoader
)
# 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
())]
db_dir
=
parse_output_path
(
f
'
{
args
.
out_dir
}
dbs/
'
)
logs_dir
=
parse_output_path
(
f
'
{
args
.
out_dir
}
logs/
'
)
...
...
@@ -104,9 +105,12 @@ def main(args):
algo
=
hp
.
tpe
.
suggest
,
trials
=
trials
,
max_evals
=
args
.
hyperopt_iters
)
print
(
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
])
for
p
in
ranges_dict
[
'
nonvariable
'
]:
out_param_dict
[
p
]
=
ranges_dict
[
'
nonvariable
'
][
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
]
# store hyperparams as new parameter file
with
open
(
f
'
{
args
.
out_dir
}
parameterFile.yaml
'
,
'
w
'
)
as
fh
:
fh
.
write
(
generate_header
(
trials
.
losses
()[
-
1
]))
...
...
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