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
082e65c9
Commit
082e65c9
authored
Jun 08, 2017
by
Toby Boyd
Browse files
iput pipeline on CPU. 1700 images/sec to 8000 on GTX 1080
parent
68a18b70
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
5 deletions
+13
-5
tutorials/image/cifar10/cifar10_multi_gpu_train.py
tutorials/image/cifar10/cifar10_multi_gpu_train.py
+9
-4
tutorials/image/cifar10/cifar10_train.py
tutorials/image/cifar10/cifar10_train.py
+4
-1
No files found.
tutorials/image/cifar10/cifar10_multi_gpu_train.py
View file @
082e65c9
...
@@ -62,7 +62,7 @@ tf.app.flags.DEFINE_boolean('log_device_placement', False,
...
@@ -62,7 +62,7 @@ tf.app.flags.DEFINE_boolean('log_device_placement', False,
"""Whether to log device placement."""
)
"""Whether to log device placement."""
)
def
tower_loss
(
scope
):
def
tower_loss
(
scope
,
images
,
labels
):
"""Calculate the total loss on a single tower running the CIFAR model.
"""Calculate the total loss on a single tower running the CIFAR model.
Args:
Args:
...
@@ -71,8 +71,7 @@ def tower_loss(scope):
...
@@ -71,8 +71,7 @@ def tower_loss(scope):
Returns:
Returns:
Tensor of shape [] containing the total loss for a batch of data
Tensor of shape [] containing the total loss for a batch of data
"""
"""
# Get images and labels for CIFAR-10.
images
,
labels
=
cifar10
.
distorted_inputs
()
# Build inference Graph.
# Build inference Graph.
logits
=
cifar10
.
inference
(
images
)
logits
=
cifar10
.
inference
(
images
)
...
@@ -160,6 +159,12 @@ def train():
...
@@ -160,6 +159,12 @@ def train():
# Create an optimizer that performs gradient descent.
# Create an optimizer that performs gradient descent.
opt
=
tf
.
train
.
GradientDescentOptimizer
(
lr
)
opt
=
tf
.
train
.
GradientDescentOptimizer
(
lr
)
# Get images and labels for CIFAR-10.
# Force input pipeline to CPU:0 to avoid opertaios sometimes ending up on GPU
# and resulting in a slow down.
with
tf
.
device
(
'/CPU:0'
):
images
,
labels
=
cifar10
.
distorted_inputs
()
# Calculate the gradients for each model tower.
# Calculate the gradients for each model tower.
tower_grads
=
[]
tower_grads
=
[]
with
tf
.
variable_scope
(
tf
.
get_variable_scope
()):
with
tf
.
variable_scope
(
tf
.
get_variable_scope
()):
...
@@ -169,7 +174,7 @@ def train():
...
@@ -169,7 +174,7 @@ def train():
# Calculate the loss for one tower of the CIFAR model. This function
# Calculate the loss for one tower of the CIFAR model. This function
# constructs the entire CIFAR model but shares the variables across
# constructs the entire CIFAR model but shares the variables across
# all towers.
# all towers.
loss
=
tower_loss
(
scope
)
loss
=
tower_loss
(
scope
,
images
,
labels
)
# Reuse variables for the next tower.
# Reuse variables for the next tower.
tf
.
get_variable_scope
().
reuse_variables
()
tf
.
get_variable_scope
().
reuse_variables
()
...
...
tutorials/image/cifar10/cifar10_train.py
View file @
082e65c9
...
@@ -62,7 +62,10 @@ def train():
...
@@ -62,7 +62,10 @@ def train():
global_step
=
tf
.
contrib
.
framework
.
get_or_create_global_step
()
global_step
=
tf
.
contrib
.
framework
.
get_or_create_global_step
()
# Get images and labels for CIFAR-10.
# Get images and labels for CIFAR-10.
images
,
labels
=
cifar10
.
distorted_inputs
()
# Force input pipeline to CPU:0 to avoid opertaios sometimes ending up
# on GPU and resulting in a slow down.
with
tf
.
device
(
'/CPU:0'
):
images
,
labels
=
cifar10
.
distorted_inputs
()
# Build a Graph that computes the logits predictions from the
# Build a Graph that computes the logits predictions from the
# inference model.
# inference model.
...
...
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