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
6c965160
Commit
6c965160
authored
Aug 20, 2019
by
Vinh Nguyen
Browse files
Merge remote-tracking branch 'origin/amp_transformer' into amp_resnet50
parents
901c4cc4
b8f58ec8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
1 deletion
+10
-1
official/transformer/v2/misc.py
official/transformer/v2/misc.py
+4
-1
official/transformer/v2/transformer_main.py
official/transformer/v2/transformer_main.py
+6
-0
No files found.
official/transformer/v2/misc.py
View file @
6c965160
...
@@ -85,7 +85,10 @@ def define_transformer_flags():
...
@@ -85,7 +85,10 @@ def define_transformer_flags():
'convolutions and batch normalizations, and this flag allows to '
'convolutions and batch normalizations, and this flag allows to '
'disable it.'
'disable it.'
)
)
flags
.
DEFINE_boolean
(
name
=
'automatic_mixed_precision'
,
default
=
False
,
help
=
'Enable automatic mixed precision training via a graph rewrite.'
)
flags_core
.
define_benchmark
()
flags_core
.
define_benchmark
()
flags_core
.
define_device
(
tpu
=
True
)
flags_core
.
define_device
(
tpu
=
True
)
...
...
official/transformer/v2/transformer_main.py
View file @
6c965160
...
@@ -376,6 +376,12 @@ class TransformerTask(object):
...
@@ -376,6 +376,12 @@ class TransformerTask(object):
opt
=
tf
.
keras
.
mixed_precision
.
experimental
.
LossScaleOptimizer
(
opt
=
tf
.
keras
.
mixed_precision
.
experimental
.
LossScaleOptimizer
(
opt
,
loss_scale
=
flags_core
.
get_loss_scale
(
self
.
flags_obj
,
opt
,
loss_scale
=
flags_core
.
get_loss_scale
(
self
.
flags_obj
,
default_for_fp16
=
"dynamic"
))
default_for_fp16
=
"dynamic"
))
if
self
.
flags_obj
.
automatic_mixed_precision
:
if
params
[
"dtype"
]
==
tf
.
float16
:
raise
RuntimeError
(
"Automatic mixed precision should not be called in conjunction with "
"other types of mixed precision training. Set --dtype=fp32 instead."
)
opt
=
tf
.
compat
.
v1
.
train
.
experimental
.
enable_mixed_precision_graph_rewrite
(
opt
)
return
opt
return
opt
...
...
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