Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MLAir
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
Container registry
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
esde
machine-learning
MLAir
Commits
bc989d62
Commit
bc989d62
authored
4 years ago
by
lukas leufen
Browse files
Options
Downloads
Patches
Plain Diff
update tests
parent
02e43daa
No related branches found
No related tags found
3 merge requests
!125
Release v0.10.0
,
!124
Update Master to new version v0.10.0
,
!101
Resolve "model folder in experiment"
Pipeline
#39298
failed
4 years ago
Stage: test
Stage: docs
Stage: pages
Stage: deploy
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/test_modules/test_training.py
+20
-12
20 additions, 12 deletions
test/test_modules/test_training.py
with
20 additions
and
12 deletions
test/test_modules/test_training.py
+
20
−
12
View file @
bc989d62
...
...
@@ -47,7 +47,7 @@ def my_test_model(activation, window_history_size, channels, dropout_rate, add_m
class
TestTraining
:
@pytest.fixture
def
init_without_run
(
self
,
path
:
str
,
model
:
keras
.
Model
,
callbacks
:
CallbackHandler
):
def
init_without_run
(
self
,
path
:
str
,
model
:
keras
.
Model
,
callbacks
:
CallbackHandler
,
model_path
):
obj
=
object
.
__new__
(
Training
)
super
(
Training
,
obj
).
__init__
()
obj
.
model
=
model
...
...
@@ -66,7 +66,9 @@ class TestTraining:
obj
.
data_store
.
set
(
"
generator
"
,
mock
.
MagicMock
(
return_value
=
"
mock_test_gen
"
),
"
general.test
"
)
os
.
makedirs
(
path
)
obj
.
data_store
.
set
(
"
experiment_path
"
,
path
,
"
general
"
)
obj
.
data_store
.
set
(
"
model_name
"
,
os
.
path
.
join
(
path
,
"
test_model.h5
"
),
"
general.model
"
)
os
.
makedirs
(
model_path
)
obj
.
data_store
.
set
(
"
model_path
"
,
model_path
,
"
general
"
)
obj
.
data_store
.
set
(
"
model_name
"
,
os
.
path
.
join
(
model_path
,
"
test_model.h5
"
),
"
general.model
"
)
obj
.
data_store
.
set
(
"
experiment_name
"
,
"
TestExperiment
"
,
"
general
"
)
path_plot
=
os
.
path
.
join
(
path
,
"
plots
"
)
os
.
makedirs
(
path_plot
)
...
...
@@ -100,6 +102,10 @@ class TestTraining:
def
path
(
self
):
return
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
"
TestExperiment
"
)
@pytest.fixture
def
model_path
(
self
,
path
):
return
os
.
path
.
join
(
path
,
"
model
"
)
@pytest.fixture
def
generator
(
self
,
path
):
return
DataGenerator
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'
data
'
),
'
AIRBASE
'
,
...
...
@@ -138,15 +144,17 @@ class TestTraining:
return
obj
@pytest.fixture
def
ready_to_init
(
self
,
generator
,
model
,
callbacks
,
path
):
def
ready_to_init
(
self
,
generator
,
model
,
callbacks
,
path
,
model_
path
):
os
.
makedirs
(
path
)
os
.
makedirs
(
model_path
)
obj
=
RunEnvironment
()
obj
.
data_store
.
set
(
"
generator
"
,
generator
,
"
general.train
"
)
obj
.
data_store
.
set
(
"
generator
"
,
generator
,
"
general.val
"
)
obj
.
data_store
.
set
(
"
generator
"
,
generator
,
"
general.test
"
)
model
.
compile
(
optimizer
=
keras
.
optimizers
.
SGD
(),
loss
=
keras
.
losses
.
mean_absolute_error
)
obj
.
data_store
.
set
(
"
model
"
,
model
,
"
general.model
"
)
obj
.
data_store
.
set
(
"
model_name
"
,
os
.
path
.
join
(
path
,
"
test_model.h5
"
),
"
general.model
"
)
obj
.
data_store
.
set
(
"
model_path
"
,
model_path
,
"
general
"
)
obj
.
data_store
.
set
(
"
model_name
"
,
os
.
path
.
join
(
model_path
,
"
test_model.h5
"
),
"
general.model
"
)
obj
.
data_store
.
set
(
"
batch_size
"
,
256
,
"
general.model
"
)
obj
.
data_store
.
set
(
"
epochs
"
,
2
,
"
general.model
"
)
clbk
,
hist
,
lr
=
callbacks
...
...
@@ -212,23 +220,23 @@ class TestTraining:
assert
caplog
.
record_tuples
[
0
]
==
(
"
root
"
,
10
,
PyTestRegex
(
"
load best model: notExisting
"
))
assert
caplog
.
record_tuples
[
1
]
==
(
"
root
"
,
20
,
PyTestRegex
(
"
no weights to reload...
"
))
def
test_save_callbacks_history_created
(
self
,
init_without_run
,
history
,
learning_rate
,
path
):
def
test_save_callbacks_history_created
(
self
,
init_without_run
,
history
,
learning_rate
,
model_
path
):
init_without_run
.
save_callbacks_as_json
(
history
,
learning_rate
)
assert
"
history.json
"
in
os
.
listdir
(
path
)
assert
"
history.json
"
in
os
.
listdir
(
model_
path
)
def
test_save_callbacks_lr_created
(
self
,
init_without_run
,
history
,
learning_rate
,
path
):
def
test_save_callbacks_lr_created
(
self
,
init_without_run
,
history
,
learning_rate
,
model_
path
):
init_without_run
.
save_callbacks_as_json
(
history
,
learning_rate
)
assert
"
history_lr.json
"
in
os
.
listdir
(
path
)
assert
"
history_lr.json
"
in
os
.
listdir
(
model_
path
)
def
test_save_callbacks_inspect_history
(
self
,
init_without_run
,
history
,
learning_rate
,
path
):
def
test_save_callbacks_inspect_history
(
self
,
init_without_run
,
history
,
learning_rate
,
model_
path
):
init_without_run
.
save_callbacks_as_json
(
history
,
learning_rate
)
with
open
(
os
.
path
.
join
(
path
,
"
history.json
"
))
as
jfile
:
with
open
(
os
.
path
.
join
(
model_
path
,
"
history.json
"
))
as
jfile
:
hist
=
json
.
load
(
jfile
)
assert
hist
==
history
.
history
def
test_save_callbacks_inspect_lr
(
self
,
init_without_run
,
history
,
learning_rate
,
path
):
def
test_save_callbacks_inspect_lr
(
self
,
init_without_run
,
history
,
learning_rate
,
model_
path
):
init_without_run
.
save_callbacks_as_json
(
history
,
learning_rate
)
with
open
(
os
.
path
.
join
(
path
,
"
history_lr.json
"
))
as
jfile
:
with
open
(
os
.
path
.
join
(
model_
path
,
"
history_lr.json
"
))
as
jfile
:
lr
=
json
.
load
(
jfile
)
assert
lr
==
learning_rate
.
lr
...
...
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