Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
deepOF
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
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
Service Desk
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
Lucas Miranda
deepOF
Commits
5693df25
Commit
5693df25
authored
4 years ago
by
Lucas Miranda
Browse files
Options
Downloads
Patches
Plain Diff
Fixed deepof.train_utils.tune_search
parent
6a060a56
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#103648
passed
4 years ago
Stage: test
Stage: deploy
Changes
3
Pipelines
1
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
deepof/train_utils.py
+5
-4
5 additions, 4 deletions
deepof/train_utils.py
supplementary_notebooks/deepof_data_exploration.ipynb
+78
-31
78 additions, 31 deletions
supplementary_notebooks/deepof_data_exploration.ipynb
tests/test_train_utils.py
+16
-8
16 additions, 8 deletions
tests/test_train_utils.py
with
99 additions
and
43 deletions
deepof/train_utils.py
+
5
−
4
View file @
5693df25
...
...
@@ -15,7 +15,7 @@ from typing import Tuple, Union, Any, List
import
numpy
as
np
import
tensorflow
as
tf
from
kerastuner
import
BayesianOptimization
,
Hyperband
from
kerastuner
import
BayesianOptimization
,
Hyperband
,
Objective
from
kerastuner_tensorboard_logger
import
TensorBoardLogger
from
sklearn.metrics
import
roc_auc_score
from
tensorboard.plugins.hparams
import
api
as
hp
...
...
@@ -562,7 +562,7 @@ def tune_search(
"
logger
"
:
TensorBoardLogger
(
metrics
=
[
tuner_objective
],
logdir
=
os
.
path
.
join
(
outpath
,
"
logged_hparams
"
)
),
"
objective
"
:
tuner_objective
,
"
objective
"
:
Objective
(
tuner_objective
,
direction
=
"
min
"
),
"
project_name
"
:
project_name
,
"
tune_new_entries
"
:
True
,
}
...
...
@@ -588,8 +588,8 @@ def tune_search(
print
(
tuner
.
search_space_summary
())
Xs
,
ys
=
[
X_train
]
,
[
X_train
]
Xvals
,
yvals
=
[
X_val
]
,
[
X_val
]
Xs
,
ys
=
X_train
,
[
X_train
]
Xvals
,
yvals
=
X_val
,
[
X_val
]
if
next_sequence_prediction
>
0.0
:
Xs
,
ys
=
X_train
[:
-
1
],
[
X_train
[:
-
1
],
X_train
[
1
:]]
...
...
@@ -607,6 +607,7 @@ def tune_search(
ys
+=
[
y_train
[
-
Xs
.
shape
[
0
]
:]]
yvals
+=
[
y_val
[
-
Xvals
.
shape
[
0
]
:]]
# Convert data to tf.data.Dataset objects
tuner
.
search
(
Xs
,
ys
,
...
...
This diff is collapsed.
Click to expand it.
supplementary_notebooks/deepof_data_exploration.ipynb
+
78
−
31
View file @
5693df25
This diff is collapsed.
Click to expand it.
tests/test_train_utils.py
+
16
−
8
View file @
5693df25
...
...
@@ -133,7 +133,7 @@ def test_autoencoder_fitting(
)
@settings
(
max_examples
=
1
5
,
deadline
=
None
)
@settings
(
max_examples
=
5
,
deadline
=
None
)
@given
(
X_train
=
arrays
(
dtype
=
float
,
...
...
@@ -147,6 +147,7 @@ def test_autoencoder_fitting(
max_value
=
1
,
),
),
y_train
=
st
.
data
(),
batch_size
=
st
.
integers
(
min_value
=
128
,
max_value
=
512
),
encoding_size
=
st
.
integers
(
min_value
=
1
,
max_value
=
16
),
hpt_type
=
st
.
one_of
(
st
.
just
(
"
bayopt
"
),
st
.
just
(
"
hyperband
"
)),
...
...
@@ -159,6 +160,7 @@ def test_autoencoder_fitting(
)
def
test_tune_search
(
X_train
,
y_train
,
batch_size
,
encoding_size
,
hpt_type
,
...
...
@@ -173,9 +175,9 @@ def test_tune_search(
deepof
.
train_utils
.
get_callbacks
(
X_train
=
X_train
,
batch_size
=
batch_size
,
phenotype_prediction
=
phenotype_prediction
,
next_sequence_prediction
=
next_sequence_prediction
,
rule_based_prediction
=
rule_based_prediction
,
phenotype_prediction
=
np
.
round
(
phenotype_prediction
,
2
),
next_sequence_prediction
=
np
.
round
(
next_sequence_prediction
,
2
),
rule_based_prediction
=
np
.
round
(
rule_based_prediction
,
2
),
loss
=
loss
,
X_val
=
X_train
,
input_type
=
False
,
...
...
@@ -189,7 +191,13 @@ def test_tune_search(
)
)[
1
:]
y_train
=
tf
.
random
.
uniform
(
shape
=
(
X_train
.
shape
[
1
],
1
),
maxval
=
1.0
)
y_train
=
y_train
.
draw
(
arrays
(
dtype
=
np
.
float32
,
elements
=
st
.
floats
(
min_value
=
0.0
,
max_value
=
1.0
,
width
=
32
),
shape
=
(
X_train
.
shape
[
1
],
1
),
)
)
deepof
.
train_utils
.
tune_search
(
data
=
[
X_train
,
y_train
,
X_train
,
y_train
],
...
...
@@ -201,9 +209,9 @@ def test_tune_search(
loss
=
loss
,
mmd_warmup_epochs
=
0
,
overlap_loss
=
overlap_loss
,
next_sequence_prediction
=
next_sequence_prediction
,
phenotype_prediction
=
phenotype_prediction
,
rule_based_prediction
=
rule_based_prediction
,
next_sequence_prediction
=
np
.
round
(
next_sequence_prediction
,
2
),
phenotype_prediction
=
np
.
round
(
phenotype_prediction
,
2
),
rule_based_prediction
=
np
.
round
(
rule_based_prediction
,
2
),
project_name
=
"
test_run
"
,
callbacks
=
callbacks
,
n_epochs
=
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