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
c254938d
Commit
c254938d
authored
Dec 08, 2018
by
Priya Gupta
Browse files
Add option to turn on eager in imagenet
parent
52ee9636
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
0 deletions
+9
-0
official/resnet/keras/keras_imagenet_main.py
official/resnet/keras/keras_imagenet_main.py
+9
-0
No files found.
official/resnet/keras/keras_imagenet_main.py
View file @
c254938d
...
...
@@ -189,6 +189,9 @@ def run_imagenet_with_keras(flags_obj):
Raises:
ValueError: If fp16 is passed as it is not currently supported.
"""
if
flags_obj
.
enable_eager
:
tf
.
enable_eager_execution
()
dtype
=
flags_core
.
get_tf_dtype
(
flags_obj
)
if
dtype
==
'fp16'
:
raise
ValueError
(
'dtype fp16 is not supported in Keras. Use the default '
...
...
@@ -247,6 +250,7 @@ def run_imagenet_with_keras(flags_obj):
# learning_rate = BASE_LEARNING_RATE * flags_obj.batch_size / 256
# opt = tf.train.MomentumOptimizer(learning_rate=learning_rate, momentum=0.9)
strategy
=
distribution_utils
.
get_distribution_strategy
(
num_gpus
=
flags_obj
.
num_gpus
)
...
...
@@ -295,6 +299,10 @@ def run_imagenet_with_keras(flags_obj):
verbose
=
1
)
print
(
'Test loss:'
,
eval_output
[
0
])
def
define_keras_imagenet_flags
():
flags
.
DEFINE_boolean
(
name
=
'enable_eager'
,
default
=
False
,
help
=
'Enable eager?'
)
def
main
(
_
):
with
logger
.
benchmark_context
(
flags
.
FLAGS
):
run_imagenet_with_keras
(
flags
.
FLAGS
)
...
...
@@ -302,5 +310,6 @@ def main(_):
if
__name__
==
'__main__'
:
tf
.
logging
.
set_verbosity
(
tf
.
logging
.
INFO
)
define_keras_imagenet_flags
()
imagenet_main
.
define_imagenet_flags
()
absl_app
.
run
(
main
)
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