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
Nikolai.Hartmann
KerasROOTClassification
Commits
01681528
Commit
01681528
authored
6 years ago
by
Nikolai.Hartmann
Browse files
Options
Downloads
Patches
Plain Diff
Switch saving options of new projects to pickle, but maintain support for json
parent
8b1f3c2e
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
browse.py
+4
-0
4 additions, 0 deletions
browse.py
toolkit.py
+22
-4
22 additions, 4 deletions
toolkit.py
with
26 additions
and
4 deletions
browse.py
+
4
−
0
View file @
01681528
import
sys
import
sys
import
logging
import
numpy
as
np
import
numpy
as
np
import
matplotlib.pyplot
as
plt
import
matplotlib.pyplot
as
plt
from
KerasROOTClassification
import
*
from
KerasROOTClassification
import
*
logging
.
basicConfig
()
logging
.
getLogger
(
"
KerasROOTClassification
"
).
setLevel
(
logging
.
INFO
)
c
=
ClassificationProject
(
sys
.
argv
[
1
])
c
=
ClassificationProject
(
sys
.
argv
[
1
])
This diff is collapsed.
Click to expand it.
toolkit.py
+
22
−
4
View file @
01681528
...
@@ -52,6 +52,19 @@ K.set_session(session)
...
@@ -52,6 +52,19 @@ K.set_session(session)
import
ROOT
import
ROOT
def
byteify
(
input
):
"
From stackoverflow https://stackoverflow.com/a/13105359
"
if
isinstance
(
input
,
dict
):
return
{
byteify
(
key
):
byteify
(
value
)
for
key
,
value
in
input
.
iteritems
()}
elif
isinstance
(
input
,
list
):
return
[
byteify
(
element
)
for
element
in
input
]
elif
isinstance
(
input
,
unicode
):
return
input
.
encode
(
'
utf-8
'
)
else
:
return
input
class
ClassificationProject
(
object
):
class
ClassificationProject
(
object
):
"""
Simple framework to load data from ROOT TTrees and train Keras
"""
Simple framework to load data from ROOT TTrees and train Keras
...
@@ -144,13 +157,18 @@ class ClassificationProject(object):
...
@@ -144,13 +157,18 @@ class ClassificationProject(object):
else
:
else
:
# otherwise initialise new project
# otherwise initialise new project
self
.
_init_from_args
(
name
,
*
args
,
**
kwargs
)
self
.
_init_from_args
(
name
,
*
args
,
**
kwargs
)
with
open
(
os
.
path
.
join
(
self
.
project_dir
,
"
options.
json
"
),
"
w
"
)
as
of
:
with
open
(
os
.
path
.
join
(
self
.
project_dir
,
"
options.
pickle
"
),
"
w
"
)
as
of
:
json
.
dump
(
dict
(
args
=
args
,
kwargs
=
kwargs
),
of
)
pickle
.
dump
(
dict
(
args
=
args
,
kwargs
=
kwargs
),
of
)
def
_init_from_dir
(
self
,
dirname
):
def
_init_from_dir
(
self
,
dirname
):
with
open
(
os
.
path
.
join
(
dirname
,
"
options.json
"
))
as
f
:
if
not
os
.
path
.
exists
(
os
.
path
.
join
(
dirname
,
"
options.pickle
"
)):
options
=
yaml
.
safe_load
(
f
)
# for backward compatibility
with
open
(
os
.
path
.
join
(
dirname
,
"
options.json
"
))
as
f
:
options
=
byteify
(
json
.
load
(
f
))
else
:
with
open
(
os
.
path
.
join
(
dirname
,
"
options.pickle
"
))
as
f
:
options
=
pickle
.
load
(
f
)
options
[
"
kwargs
"
][
"
project_dir
"
]
=
dirname
options
[
"
kwargs
"
][
"
project_dir
"
]
=
dirname
self
.
_init_from_args
(
os
.
path
.
basename
(
dirname
),
*
options
[
"
args
"
],
**
options
[
"
kwargs
"
])
self
.
_init_from_args
(
os
.
path
.
basename
(
dirname
),
*
options
[
"
args
"
],
**
options
[
"
kwargs
"
])
...
...
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