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
d9f78c70
Commit
d9f78c70
authored
6 years ago
by
Nikolai.Hartmann
Browse files
Options
Downloads
Patches
Plain Diff
loss function configurable
parent
a027593b
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
+8
-4
8 additions, 4 deletions
toolkit.py
with
8 additions
and
4 deletions
toolkit.py
+
8
−
4
View file @
d9f78c70
...
...
@@ -150,6 +150,8 @@ class ClassificationProject(object):
random data is also used for shuffling the training data, so results may vary still. To
produce consistent results, set the numpy random seed before training.
:param loss: loss function name
"""
...
...
@@ -205,7 +207,8 @@ class ClassificationProject(object):
use_modelcheckpoint
=
True
,
modelcheckpoint_opts
=
None
,
random_seed
=
1234
,
balance_dataset
=
False
):
balance_dataset
=
False
,
loss
=
'
binary_crossentropy
'
):
self
.
name
=
name
self
.
signal_trees
=
signal_trees
...
...
@@ -253,6 +256,7 @@ class ClassificationProject(object):
self
.
modelcheckpoint_opts
=
modelcheckpoint_opts
self
.
random_seed
=
random_seed
self
.
balance_dataset
=
balance_dataset
self
.
loss
=
loss
self
.
s_train
=
None
self
.
b_train
=
None
...
...
@@ -562,7 +566,7 @@ class ClassificationProject(object):
rn_state
=
np
.
random
.
get_state
()
np
.
random
.
seed
(
self
.
random_seed
)
self
.
_model
.
compile
(
optimizer
=
optimizer
,
loss
=
'
binary_crossentropy
'
,
loss
=
self
.
loss
,
metrics
=
[
'
accuracy
'
])
np
.
random
.
set_state
(
rn_state
)
if
os
.
path
.
exists
(
os
.
path
.
join
(
self
.
project_dir
,
"
weights.h5
"
)):
...
...
@@ -1031,7 +1035,7 @@ class ClassificationProject(object):
plt
.
plot
(
hist_dict
[
'
val_loss
'
])
plt
.
ylabel
(
'
loss
'
)
plt
.
xlabel
(
'
epoch
'
)
plt
.
legend
([
'
train
'
,
'
test
'
],
loc
=
'
upper left
'
)
plt
.
legend
([
'
train
ing data
'
,
'
validation data
'
],
loc
=
'
upper left
'
)
if
log
:
plt
.
yscale
(
"
log
"
)
if
xlim
is
not
None
:
...
...
@@ -1065,7 +1069,7 @@ class ClassificationProject(object):
plt
.
title
(
'
model accuracy
'
)
plt
.
ylabel
(
'
accuracy
'
)
plt
.
xlabel
(
'
epoch
'
)
plt
.
legend
([
'
train
'
,
'
test
'
],
loc
=
'
upper left
'
)
plt
.
legend
([
'
train
ing data
'
,
'
validation data
'
],
loc
=
'
upper left
'
)
if
log
:
plt
.
yscale
(
"
log
"
)
plt
.
savefig
(
os
.
path
.
join
(
self
.
project_dir
,
"
accuracy.pdf
"
))
...
...
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