Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Lucas Miranda
deepOF
Commits
22822aae
Commit
22822aae
authored
Dec 07, 2020
by
lucas_miranda
Browse files
Added CustomStopper class to train_utils.py, to start early stopping only after annealing is over
parent
5b343dc4
Pipeline
#89029
failed with stage
in 120 minutes and 9 seconds
Changes
2
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
deepof/train_utils.py
View file @
22822aae
...
...
@@ -23,6 +23,25 @@ import tensorflow as tf
hp
=
HyperParameters
()
class
CustomStopper
(
tf
.
keras
.
callbacks
.
EarlyStopping
):
""" Custom callback for """
def
__init__
(
self
,
start_epoch
,
*
args
,
**
kwargs
):
super
(
CustomStopper
,
self
).
__init__
(
*
args
,
**
kwargs
)
self
.
start_epoch
=
start_epoch
def
get_config
(
self
):
# pragma: no cover
"""Updates callback metadata"""
config
=
super
().
get_config
().
copy
()
config
.
update
({
"start_epoch"
:
self
.
start_epoch
})
return
config
def
on_epoch_end
(
self
,
epoch
,
logs
=
None
):
if
epoch
>
self
.
start_epoch
:
super
().
on_epoch_end
(
epoch
,
logs
)
def
load_hparams
(
hparams
):
"""Loads hyperparameters from a custom dictionary pickled on disc.
Thought to be used with the output of hyperparameter_tuning.py"""
...
...
examples/main.ipynb
View file @
22822aae
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment