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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
esde
machine-learning
MLAir
Merge requests
!11
finish run script creation, /close
#11
Code
Review changes
Check out branch
Download
Patches
Plain diff
Expand sidebar
Merged
finish run script creation, /close
#11
lukas_issue011_feat_run-script
into
develop
Overview
0
Commits
9
Pipelines
1
Changes
5
Merged
finish run script creation, /close #11
Ghost User
requested to merge
lukas_issue011_feat_run-script
into
develop
Nov 15, 2019
Overview
0
Commits
9
Pipelines
1
Changes
5
include in dev
#11 (closed)
,
#12 (closed)
,
#22 (closed)
0
0
Merge request reports
Compare
develop
develop (base)
and
latest version
latest version
1cfd0353
9 commits,
Nov 15, 2019
5 files
+
344
−
1
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
5
src/helpers.py
+
85
−
0
View file @ 1cfd0353
Edit in single-file editor
Open in Web IDE
Show full file
@@ -9,6 +9,9 @@ import math
from
typing
import
Union
import
numpy
as
np
import
os
import
time
import
socket
import
sys
def
to_list
(
arg
):
@@ -84,3 +87,85 @@ class LearningRateDecay(keras.callbacks.History):
self
.
lr
[
'
lr
'
].
append
(
current_lr
)
logging
.
info
(
f
"
Set learning rate to
{
current_lr
}
"
)
return
K
.
get_value
(
self
.
model
.
optimizer
.
lr
)
class
TimeTracking
(
object
):
"""
Track time to measure execution time. Time tracking automatically starts on initialisation and ends by calling stop
method. Duration can always be shown by printing the time tracking object or calling get_current_duration.
"""
def
__init__
(
self
,
start
=
True
):
self
.
start
=
None
self
.
end
=
None
if
start
:
self
.
_start
()
def
_start
(
self
):
self
.
start
=
time
.
time
()
self
.
end
=
None
def
_end
(
self
):
self
.
end
=
time
.
time
()
def
_duration
(
self
):
if
self
.
end
:
return
self
.
end
-
self
.
start
else
:
return
time
.
time
()
-
self
.
start
def
__repr__
(
self
):
return
f
"
{
round
(
self
.
_duration
(),
2
)
}
s
"
def
run
(
self
):
self
.
_start
()
def
stop
(
self
,
get_duration
=
False
):
if
self
.
end
is
None
:
self
.
_end
()
else
:
msg
=
f
"
Time was already stopped
{
time
.
time
()
-
self
.
end
}
s ago.
"
logging
.
error
(
msg
)
raise
AssertionError
(
msg
)
if
get_duration
:
return
self
.
duration
()
def
duration
(
self
):
return
self
.
_duration
()
def
prepare_host
():
hostname
=
socket
.
gethostname
()
user
=
os
.
getlogin
()
if
hostname
==
'
ZAM144
'
:
path
=
f
'
/home/
{
user
}
/Data/toar_daily/
'
elif
hostname
==
'
zam347
'
:
path
=
f
'
/home/
{
user
}
/Data/toar_daily/
'
elif
hostname
==
'
linux-gzsx
'
:
path
=
f
'
/home/
{
user
}
/machinelearningtools
'
elif
(
len
(
hostname
)
>
2
)
and
(
hostname
[:
2
]
==
'
jr
'
):
path
=
f
'
/p/project/cjjsc42/
{
user
}
/DATA/toar_daily/
'
elif
(
len
(
hostname
)
>
2
)
and
(
hostname
[:
2
]
==
'
jw
'
):
path
=
f
'
/p/home/jusers/
{
user
}
/juwels/intelliaq/DATA/toar_daily/
'
else
:
logging
.
error
(
f
"
unknown host
'
{
hostname
}
'"
)
raise
OSError
(
f
"
unknown host
'
{
hostname
}
'"
)
if
not
os
.
path
.
exists
(
path
):
logging
.
error
(
f
"
path
'
{
path
}
'
does not exist for host
'
{
hostname
}
'
.
"
)
raise
NotADirectoryError
(
f
"
path
'
{
path
}
'
does not exist for host
'
{
hostname
}
'
.
"
)
else
:
logging
.
info
(
f
"
set path to:
{
path
}
"
)
return
path
def
set_experiment_name
(
experiment_date
=
None
,
experiment_path
=
None
):
if
experiment_date
is
None
:
experiment_name
=
"
TestExperiment
"
else
:
experiment_name
=
f
"
{
experiment_date
}
_network/
"
if
experiment_path
is
None
:
experiment_path
=
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
"
..
"
,
experiment_name
))
else
:
experiment_path
=
os
.
path
.
abspath
(
experiment_path
)
return
experiment_name
,
experiment_path
Loading