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
122bb012
Commit
122bb012
authored
Dec 23, 2018
by
Toby Boyd
Browse files
fix lint errors.
parent
d945e99f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
9 deletions
+11
-9
official/utils/misc/distribution_utils.py
official/utils/misc/distribution_utils.py
+11
-9
No files found.
official/utils/misc/distribution_utils.py
View file @
122bb012
...
...
@@ -21,8 +21,9 @@ from __future__ import print_function
import
tensorflow
as
tf
def
get_distribution_strategy
(
num_gpus
,
all_reduce_alg
=
None
,
turn_off_distribution_strategy
=
False
):
def
get_distribution_strategy
(
num_gpus
,
all_reduce_alg
=
None
,
turn_off_distribution_strategy
=
False
):
"""Return a DistributionStrategy for running the model.
Args:
...
...
@@ -42,19 +43,20 @@ def get_distribution_strategy(
larger than 1
"""
if
num_gpus
==
0
:
if
turn_off_distribution_strategy
:
return
None
else
:
return
tf
.
contrib
.
distribute
.
OneDeviceStrategy
(
"device:CPU:0"
)
if
turn_off_distribution_strategy
:
return
None
else
:
return
tf
.
contrib
.
distribute
.
OneDeviceStrategy
(
"device:CPU:0"
)
elif
num_gpus
==
1
:
if
turn_off_distribution_strategy
:
return
None
else
:
return
tf
.
contrib
.
distribute
.
OneDeviceStrategy
(
"device:GPU:0"
)
elif
turn_off_distribution_strategy
:
raise
ValueError
(
"When %d GPUs are specified, turn_off_distribution_strategy"
" flag cannot be set to True."
.
format
(
num_gpus
))
else
:
# num_gpus > 1 and not turn_off_distribution_strategy
raise
ValueError
(
"When {} GPUs are specified, "
"turn_off_distribution_strategy flag cannot be set to"
"True."
.
format
(
num_gpus
))
else
:
# num_gpus > 1 and not turn_off_distribution_strategy
if
all_reduce_alg
:
return
tf
.
contrib
.
distribute
.
MirroredStrategy
(
num_gpus
=
num_gpus
,
...
...
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