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
c3b4ffc5
"python/vscode:/vscode.git/clone" did not exist on "ce6b17c0f94e6bf53633c8f324176a891e67fa7f"
Unverified
Commit
c3b4ffc5
authored
Apr 19, 2020
by
moneypi
Committed by
GitHub
Apr 18, 2020
Browse files
fix no attribute 'per_replica_batch_size' (#8406)
parent
a174bf5b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
2 deletions
+30
-2
research/deep_speech/deep_speech.py
research/deep_speech/deep_speech.py
+30
-2
No files found.
research/deep_speech/deep_speech.py
View file @
c3b4ffc5
...
...
@@ -209,6 +209,35 @@ def generate_dataset(data_dir):
speech_dataset
=
dataset
.
DeepSpeechDataset
(
train_data_conf
)
return
speech_dataset
def
per_device_batch_size
(
batch_size
,
num_gpus
):
"""For multi-gpu, batch-size must be a multiple of the number of GPUs.
Note that distribution strategy handles this automatically when used with
Keras. For using with Estimator, we need to get per GPU batch.
Args:
batch_size: Global batch size to be divided among devices. This should be
equal to num_gpus times the single-GPU batch_size for multi-gpu training.
num_gpus: How many GPUs are used with DistributionStrategies.
Returns:
Batch size per device.
Raises:
ValueError: if batch_size is not divisible by number of devices
"""
if
num_gpus
<=
1
:
return
batch_size
remainder
=
batch_size
%
num_gpus
if
remainder
:
err
=
(
'When running with multiple GPUs, batch size '
'must be a multiple of the number of available GPUs. Found {} '
'GPUs with a batch size of {}; try --batch_size={} instead.'
).
format
(
num_gpus
,
batch_size
,
batch_size
-
remainder
)
raise
ValueError
(
err
)
return
int
(
batch_size
/
num_gpus
)
def
run_deep_speech
(
_
):
"""Run deep speech training and eval loop."""
...
...
@@ -257,8 +286,7 @@ def run_deep_speech(_):
model_dir
=
flags_obj
.
model_dir
,
batch_size
=
flags_obj
.
batch_size
)
per_replica_batch_size
=
distribution_utils
.
per_replica_batch_size
(
flags_obj
.
batch_size
,
num_gpus
)
per_replica_batch_size
=
per_device_batch_size
(
flags_obj
.
batch_size
,
num_gpus
)
def
input_fn_train
():
return
dataset
.
input_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