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
0f6ff657
Commit
0f6ff657
authored
Sep 03, 2019
by
Vinh Nguyen
Browse files
adding fp16 implementation for BERT
parent
bd211e3e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
1 deletion
+10
-1
official/bert/common_flags.py
official/bert/common_flags.py
+2
-1
official/bert/run_pretraining.py
official/bert/run_pretraining.py
+8
-0
No files found.
official/bert/common_flags.py
View file @
0f6ff657
...
@@ -65,7 +65,8 @@ def define_common_bert_flags():
...
@@ -65,7 +65,8 @@ def define_common_bert_flags():
loss_scale
=
True
,
loss_scale
=
True
,
all_reduce_alg
=
False
,
all_reduce_alg
=
False
,
num_packs
=
False
,
num_packs
=
False
,
enable_xla
=
True
enable_xla
=
True
,
fp16_implementation
=
True
,
)
)
...
...
official/bert/run_pretraining.py
View file @
0f6ff657
...
@@ -127,6 +127,14 @@ def run_customized_training(strategy,
...
@@ -127,6 +127,14 @@ def run_customized_training(strategy,
bert_config
,
max_seq_length
,
max_predictions_per_seq
)
bert_config
,
max_seq_length
,
max_predictions_per_seq
)
pretrain_model
.
optimizer
=
optimization
.
create_optimizer
(
pretrain_model
.
optimizer
=
optimization
.
create_optimizer
(
initial_lr
,
steps_per_epoch
*
epochs
,
warmup_steps
)
initial_lr
,
steps_per_epoch
*
epochs
,
warmup_steps
)
if
FLAGS
.
fp16_implementation
==
'graph_rewrite'
:
# Note: when flags_obj.fp16_implementation == "graph_rewrite", dtype as
# determined by flags_core.get_tf_dtype(flags_obj) would be 'float32'
# which will ensure tf.compat.v2.keras.mixed_precision and
# tf.train.experimental.enable_mixed_precision_graph_rewrite do not double
# up.
pretrain_model
.
optimizer
=
tf
.
train
.
experimental
.
enable_mixed_precision_graph_rewrite
(
pretrain_model
.
optimizer
)
return
pretrain_model
,
core_model
return
pretrain_model
,
core_model
trained_model
=
model_training_utils
.
run_customized_training_loop
(
trained_model
=
model_training_utils
.
run_customized_training_loop
(
...
...
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