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
270c9027
Commit
270c9027
authored
4 years ago
by
lukas leufen
Browse files
Options
Downloads
Patches
Plain Diff
create model settings reporting
parent
50ec16b2
Branches
Branches containing commit
Tags
Tags containing commit
4 merge requests
!125
Release v0.10.0
,
!124
Update Master to new version v0.10.0
,
!122
Resolve "ML param reporting"
,
!119
Resolve "Include advanced data handling in workflow"
Pipeline
#41033
passed
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
mlair/run_modules/model_setup.py
+26
-0
26 additions, 0 deletions
mlair/run_modules/model_setup.py
with
26 additions
and
0 deletions
mlair/run_modules/model_setup.py
+
26
−
0
View file @
270c9027
...
...
@@ -5,8 +5,10 @@ __date__ = '2019-12-02'
import
logging
import
os
import
re
import
keras
import
pandas
as
pd
import
tensorflow
as
tf
from
mlair.model_modules.keras_extensions
import
HistoryAdvanced
,
CallbackHandler
...
...
@@ -88,6 +90,9 @@ class ModelSetup(RunEnvironment):
# compile model
self
.
compile_model
()
# report settings
self
.
report_model
()
def
_set_channels
(
self
):
"""
Set channels as number of variables of train generator.
"""
channels
=
self
.
data_store
.
get
(
"
generator
"
,
"
train
"
)[
0
][
0
].
shape
[
-
1
]
...
...
@@ -147,3 +152,24 @@ class ModelSetup(RunEnvironment):
with
tf
.
device
(
"
/cpu:0
"
):
file_name
=
f
"
{
self
.
model_name
.
rsplit
(
'
.
'
,
1
)[
0
]
}
.pdf
"
keras
.
utils
.
plot_model
(
self
.
model
,
to_file
=
file_name
,
show_shapes
=
True
,
show_layer_names
=
True
)
def
report_model
(
self
):
model_settings
=
self
.
model
.
get_settings
()
df
=
pd
.
DataFrame
(
columns
=
[
"
model setting
"
])
for
k
,
v
in
model_settings
.
items
():
if
"
<
"
in
str
(
v
):
v
=
self
.
_clean_name
(
str
(
v
))
df
.
loc
[
k
]
=
v
df
.
sort_index
(
inplace
=
True
)
column_format
=
"
ll
"
path
=
self
.
data_store
.
get
(
"
model_path
"
)
df
.
to_latex
(
os
.
path
.
join
(
path
,
"
model_settings.tex
"
),
na_rep
=
'
---
'
,
column_format
=
column_format
)
df
.
to_markdown
(
open
(
os
.
path
.
join
(
path
,
"
model_settings.md
"
),
mode
=
"
w
"
,
encoding
=
'
utf-8
'
),
tablefmt
=
"
github
"
)
@staticmethod
def
_clean_name
(
orig_name
:
str
):
mod_name
=
re
.
sub
(
r
'
^{0}
'
.
format
(
re
.
escape
(
"
<
"
)),
''
,
orig_name
).
replace
(
"'"
,
""
).
split
(
"
"
)
mod_name
=
mod_name
[
1
]
if
"
class
"
in
mod_name
[
0
]
else
mod_name
[
0
]
return
mod_name
[:
-
1
]
if
mod_name
[
-
1
]
==
"
>
"
else
mod_name
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