Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
KerasROOTClassification
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
Eric.Schanet
KerasROOTClassification
Commits
a7a38241
Commit
a7a38241
authored
6 years ago
by
Nikolai
Browse files
Options
Downloads
Patches
Plain Diff
Query if model should be retrained
parent
4f5d19bd
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
toolkit.py
+27
-4
27 additions, 4 deletions
toolkit.py
with
27 additions
and
4 deletions
toolkit.py
+
27
−
4
View file @
a7a38241
#!/usr/bin/env python
from
sys
import
version_info
if
version_info
[
0
]
>
2
:
raw_input
=
input
import
os
import
json
import
pickle
...
...
@@ -41,6 +46,7 @@ K.set_session(session)
import
ROOT
class
ClassificationProject
(
object
):
"""
Simple framework to load data from ROOT TTrees and train Keras
...
...
@@ -434,6 +440,19 @@ class ClassificationProject(object):
json
.
dump
(
info
,
of
)
@staticmethod
def
query_yn
(
text
):
result
=
None
while
result
is
None
:
input_text
=
raw_input
(
text
)
if
len
(
input_text
)
>
0
:
if
input_text
.
upper
()[
0
]
==
"
Y
"
:
result
=
True
elif
input_text
.
upper
()[
0
]
==
"
N
"
:
result
=
False
return
result
@property
def
model
(
self
):
"
Simple MLP
"
...
...
@@ -461,10 +480,14 @@ class ClassificationProject(object):
loss
=
'
binary_crossentropy
'
,
metrics
=
[
'
accuracy
'
])
np
.
random
.
set_state
(
rn_state
)
try
:
self
.
model
.
load_weights
(
os
.
path
.
join
(
self
.
project_dir
,
"
weights.h5
"
))
logger
.
info
(
"
Found and loaded previously trained weights
"
)
except
IOError
:
if
os
.
path
.
exists
(
os
.
path
.
join
(
self
.
project_dir
,
"
weights.h5
"
)):
continue_training
=
self
.
query_yn
(
"
Found previously trained weights - continue training? (Y/N)
"
)
if
continue_training
:
self
.
model
.
load_weights
(
os
.
path
.
join
(
self
.
project_dir
,
"
weights.h5
"
))
logger
.
info
(
"
Found and loaded previously trained weights
"
)
else
:
logger
.
info
(
"
Starting completely new model
"
)
else
:
logger
.
info
(
"
No weights found, starting completely new model
"
)
# dump to json for documentation
...
...
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