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
ebc28058
Commit
ebc28058
authored
Mar 10, 2020
by
Ruoxin Sang
Committed by
A. Unique TensorFlower
Mar 10, 2020
Browse files
Make the python training loop handle properly with async eager.
PiperOrigin-RevId: 300127838
parent
6e070e77
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
6 deletions
+10
-6
official/staging/training/utils.py
official/staging/training/utils.py
+10
-6
No files found.
official/staging/training/utils.py
View file @
ebc28058
...
@@ -53,13 +53,17 @@ def create_loop_fn(step_fn):
...
@@ -53,13 +53,17 @@ def create_loop_fn(step_fn):
"""
"""
try
:
try
:
step
=
0
step
=
0
while
(
num_steps
==
-
1
or
step
<
num_steps
):
# To make sure the OutOfRangeError exception can be handled well with
outputs
=
step_fn
(
iterator
)
# async remote eager, we need to wrap the loop body in a `async_scope`.
if
reduce_fn
is
not
None
:
with
tf
.
experimental
.
async_scope
():
state
=
reduce_fn
(
state
,
outputs
)
while
(
num_steps
==
-
1
or
step
<
num_steps
):
step
+=
1
outputs
=
step_fn
(
iterator
)
return
state
if
reduce_fn
is
not
None
:
state
=
reduce_fn
(
state
,
outputs
)
step
+=
1
return
state
except
(
StopIteration
,
tf
.
errors
.
OutOfRangeError
):
except
(
StopIteration
,
tf
.
errors
.
OutOfRangeError
):
tf
.
experimental
.
async_clear_error
()
return
state
return
state
return
loop_fn
return
loop_fn
...
...
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