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
4bd7de4a
Commit
4bd7de4a
authored
6 years ago
by
Nikolai.Hartmann
Browse files
Options
Downloads
Patches
Plain Diff
use ModelCheckpoint callback
parent
487774d8
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
+10
-3
10 additions, 3 deletions
toolkit.py
with
10 additions
and
3 deletions
toolkit.py
+
10
−
3
View file @
4bd7de4a
...
@@ -27,7 +27,7 @@ from sklearn.metrics import roc_curve, auc
...
@@ -27,7 +27,7 @@ from sklearn.metrics import roc_curve, auc
from
keras.models
import
Sequential
from
keras.models
import
Sequential
from
keras.layers
import
Dense
,
Dropout
from
keras.layers
import
Dense
,
Dropout
from
keras.models
import
model_from_json
from
keras.models
import
model_from_json
from
keras.callbacks
import
History
,
EarlyStopping
,
CSVLogger
from
keras.callbacks
import
History
,
EarlyStopping
,
CSVLogger
,
ModelCheckpoint
from
keras.optimizers
import
SGD
from
keras.optimizers
import
SGD
import
keras.optimizers
import
keras.optimizers
...
@@ -157,6 +157,7 @@ class ClassificationProject(object):
...
@@ -157,6 +157,7 @@ class ClassificationProject(object):
optimizer_opts
=
None
,
optimizer_opts
=
None
,
use_earlystopping
=
True
,
use_earlystopping
=
True
,
earlystopping_opts
=
None
,
earlystopping_opts
=
None
,
use_modelcheckpoint
=
True
,
random_seed
=
1234
):
random_seed
=
1234
):
self
.
name
=
name
self
.
name
=
name
...
@@ -178,6 +179,7 @@ class ClassificationProject(object):
...
@@ -178,6 +179,7 @@ class ClassificationProject(object):
self
.
step_bkg
=
step_bkg
self
.
step_bkg
=
step_bkg
self
.
optimizer
=
optimizer
self
.
optimizer
=
optimizer
self
.
use_earlystopping
=
use_earlystopping
self
.
use_earlystopping
=
use_earlystopping
self
.
use_modelcheckpoint
=
use_modelcheckpoint
if
optimizer_opts
is
None
:
if
optimizer_opts
is
None
:
optimizer_opts
=
dict
()
optimizer_opts
=
dict
()
self
.
optimizer_opts
=
optimizer_opts
self
.
optimizer_opts
=
optimizer_opts
...
@@ -354,6 +356,10 @@ class ClassificationProject(object):
...
@@ -354,6 +356,10 @@ class ClassificationProject(object):
self
.
_callbacks_list
.
append
(
self
.
history
)
self
.
_callbacks_list
.
append
(
self
.
history
)
if
self
.
use_earlystopping
:
if
self
.
use_earlystopping
:
self
.
_callbacks_list
.
append
(
EarlyStopping
(
**
self
.
earlystopping_opts
))
self
.
_callbacks_list
.
append
(
EarlyStopping
(
**
self
.
earlystopping_opts
))
if
self
.
use_modelcheckpoint
:
self
.
_callbacks_list
.
append
(
ModelCheckpoint
(
save_best_only
=
True
,
verbose
=
True
,
filepath
=
os
.
path
.
join
(
self
.
project_dir
,
"
weights.h5
"
)))
self
.
_callbacks_list
.
append
(
CSVLogger
(
os
.
path
.
join
(
self
.
project_dir
,
"
training.log
"
),
append
=
True
))
self
.
_callbacks_list
.
append
(
CSVLogger
(
os
.
path
.
join
(
self
.
project_dir
,
"
training.log
"
),
append
=
True
))
return
self
.
_callbacks_list
return
self
.
_callbacks_list
...
@@ -574,8 +580,9 @@ class ClassificationProject(object):
...
@@ -574,8 +580,9 @@ class ClassificationProject(object):
logger
.
info
(
"
Save history
"
)
logger
.
info
(
"
Save history
"
)
self
.
_dump_history
()
self
.
_dump_history
()
logger
.
info
(
"
Save weights
"
)
if
not
self
.
use_modelcheckpoint
:
self
.
model
.
save_weights
(
os
.
path
.
join
(
self
.
project_dir
,
"
weights.h5
"
))
logger
.
info
(
"
Save weights
"
)
self
.
model
.
save_weights
(
os
.
path
.
join
(
self
.
project_dir
,
"
weights.h5
"
))
self
.
total_epochs
+=
epochs
self
.
total_epochs
+=
epochs
self
.
_write_info
(
"
epochs
"
,
self
.
total_epochs
)
self
.
_write_info
(
"
epochs
"
,
self
.
total_epochs
)
...
...
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