Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
ResNet50_tensorflow
Commits
2222cefc
Commit
2222cefc
authored
May 23, 2020
by
Hongkun Yu
Committed by
A. Unique TensorFlower
May 23, 2020
Browse files
[Clean up] Remove adhoc checkpoint callback.
PiperOrigin-RevId: 312889153
parent
0798c8ba
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
24 deletions
+0
-24
official/nlp/bert/model_saving_utils.py
official/nlp/bert/model_saving_utils.py
+0
-24
No files found.
official/nlp/bert/model_saving_utils.py
View file @
2222cefc
...
@@ -75,27 +75,3 @@ def export_bert_model(model_export_path: typing.Text,
...
@@ -75,27 +75,3 @@ def export_bert_model(model_export_path: typing.Text,
latest_checkpoint_file
).
assert_existing_objects_matched
()
latest_checkpoint_file
).
assert_existing_objects_matched
()
model
.
save
(
model_export_path
,
include_optimizer
=
False
,
save_format
=
'tf'
)
model
.
save
(
model_export_path
,
include_optimizer
=
False
,
save_format
=
'tf'
)
class
BertModelCheckpoint
(
tf
.
keras
.
callbacks
.
Callback
):
"""Keras callback that saves model at the end of every epoch."""
def
__init__
(
self
,
checkpoint_dir
,
checkpoint
):
"""Initializes BertModelCheckpoint.
Arguments:
checkpoint_dir: Directory of the to be saved checkpoint file.
checkpoint: tf.train.Checkpoint object.
"""
super
(
BertModelCheckpoint
,
self
).
__init__
()
self
.
checkpoint_file_name
=
os
.
path
.
join
(
checkpoint_dir
,
'bert_training_checkpoint_step_{global_step}.ckpt'
)
assert
isinstance
(
checkpoint
,
tf
.
train
.
Checkpoint
)
self
.
checkpoint
=
checkpoint
def
on_epoch_end
(
self
,
epoch
,
logs
=
None
):
global_step
=
tf
.
keras
.
backend
.
get_value
(
self
.
model
.
optimizer
.
iterations
)
formatted_file_name
=
self
.
checkpoint_file_name
.
format
(
global_step
=
global_step
)
saved_path
=
self
.
checkpoint
.
save
(
formatted_file_name
)
logging
.
info
(
'Saving model TF checkpoint to : %s'
,
saved_path
)
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