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
f52e8ad9
Commit
f52e8ad9
authored
6 years ago
by
Nikolai
Browse files
Options
Downloads
Patches
Plain Diff
starting to develop yield_batch function for RNN
parent
9994f0ad
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
+34
-9
34 additions, 9 deletions
toolkit.py
with
34 additions
and
9 deletions
toolkit.py
+
34
−
9
View file @
f52e8ad9
...
@@ -1228,14 +1228,31 @@ class ClassificationProjectRNN(ClassificationProject):
...
@@ -1228,14 +1228,31 @@ class ClassificationProjectRNN(ClassificationProject):
"""
"""
def
__init__
(
self
,
def
__init__
(
self
,
recurrent_
branche
s
=
None
,
recurrent_
field
s
=
None
,
mask_value
=-
999
,
mask_value
=-
999
,
**
kwargs
):
**
kwargs
):
self
.
recurrent_branches
=
recurrent_branches
"""
if
self
.
recurrent_branches
is
None
:
recurrent_fields example:
self
.
recurrent_branches
=
[]
[[
"
jet1Pt
"
,
"
jet1Eta
"
,
"
jet1Phi
"
],
[
"
jet2Pt
"
,
"
jet2Eta
"
,
"
jet2Phi
"
],
[
"
jet3Pt
"
,
"
jet3Eta
"
,
"
jet3Phi
"
]],
[[
"
lep1Pt
"
,
"
lep1Eta
"
,
"
lep1Phi
"
,
"
lep1flav
"
],
[
"
lep2Pt
"
,
"
lep2Eta
"
,
"
lep2Phi
"
,
"
lep2flav
"
]],
"""
self
.
recurrent_fields
=
recurrent_fields
if
self
.
recurrent_fields
is
None
:
self
.
recurrent_fields
=
[]
for
i
,
recurrent_field
in
enumerate
(
self
.
recurrent_fields
):
self
.
recurrent_fields
[
i
]
=
np
.
array
(
recurrent_field
)
if
self
.
recurrent_fields
[
i
].
dtype
==
np
.
object
:
raise
ValueError
(
"
Invalid entry for recurrent fields: {} -
"
"
please ensure that the length for all elements in the list is equal
"
.
format
(
recurrent_field
)
)
self
.
mask_value
=
mask_value
self
.
mask_value
=
mask_value
super
(
ClassificationProjectRNN
,
self
).
__init__
()
super
(
ClassificationProjectRNN
,
self
).
__init__
()
self
.
flat_fields
=
[
field
for
field
in
self
.
fields
if
not
field
in
self
.
recurrent_fields
]
@property
@property
...
@@ -1244,12 +1261,20 @@ class ClassificationProjectRNN(ClassificationProject):
...
@@ -1244,12 +1261,20 @@ class ClassificationProjectRNN(ClassificationProject):
def
yield_batch
(
self
):
def
yield_batch
(
self
):
x_train
,
y_train
,
w_train
=
self
.
training_data
while
True
:
while
True
:
permutation
=
np
.
random
.
permutation
shuffled_idx
=
np
.
random
.
permutation
(
len
(
x_train
))
x_train
,
y_train
,
w_train
=
self
.
training_data
for
start
in
range
(
0
,
len
(
shuffled_idx
),
int
(
self
.
batch_size
)):
n_training
=
len
(
x_train
)
x_batch
=
x_train
[
shuffled_idx
[
start
:
start
+
int
(
self
.
batch_size
)]]
for
batch_start
in
range
(
0
,
n_training
,
self
.
batch_size
):
x_flat
=
x_batch
[:,
self
.
flat_fields
]
pass
x_input
=
[]
x_input
.
append
(
x_flat
)
for
recurrent_field
in
self
.
recurrent_fields
:
x_recurrent
=
x_batch
[:,
recurrent_field
.
reshape
(
-
1
)].
reshape
(
-
1
,
*
recurrent_field
.
shape
)
x_input
.
append
(
x_recurrent
)
yield
(
x_input
,
y_train
[
shuffled_idx
[
start
:
start
+
int
(
self
.
batch_size
)]],
w_train
[
shuffled_idx
[
start
:
start
+
int
(
self
.
batch_size
)]]
*
self
.
balanced_class_weight
[
class_label
])
# # shuffle the entries for this class label
# # shuffle the entries for this class label
# rn_state = np.random.get_state()
# rn_state = np.random.get_state()
# x_train[y_train==class_label] = np.random.permutation(x_train[y_train==class_label])
# x_train[y_train==class_label] = np.random.permutation(x_train[y_train==class_label])
...
...
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