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
ee968bad
Commit
ee968bad
authored
May 01, 2018
by
Asim Shankar
Browse files
official/mnist: Updates with the release of TensorFlow 1.8.
parent
505f554c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
official/mnist/mnist_eager.py
official/mnist/mnist_eager.py
+3
-3
No files found.
official/mnist/mnist_eager.py
View file @
ee968bad
...
@@ -63,7 +63,7 @@ def train(model, optimizer, dataset, step_counter, log_interval=None):
...
@@ -63,7 +63,7 @@ def train(model, optimizer, dataset, step_counter, log_interval=None):
# Record the operations used to compute the loss given the input,
# Record the operations used to compute the loss given the input,
# so that the gradient of the loss with respect to the variables
# so that the gradient of the loss with respect to the variables
# can be computed.
# can be computed.
with
tf
e
.
GradientTape
()
as
tape
:
with
tf
.
GradientTape
()
as
tape
:
logits
=
model
(
images
,
training
=
True
)
logits
=
model
(
images
,
training
=
True
)
loss_value
=
loss
(
logits
,
labels
)
loss_value
=
loss
(
logits
,
labels
)
tf
.
contrib
.
summary
.
scalar
(
'loss'
,
loss_value
)
tf
.
contrib
.
summary
.
scalar
(
'loss'
,
loss_value
)
...
@@ -99,11 +99,11 @@ def main(argv):
...
@@ -99,11 +99,11 @@ def main(argv):
parser
=
MNISTEagerArgParser
()
parser
=
MNISTEagerArgParser
()
flags
=
parser
.
parse_args
(
args
=
argv
[
1
:])
flags
=
parser
.
parse_args
(
args
=
argv
[
1
:])
tf
e
.
enable_eager_execution
()
tf
.
enable_eager_execution
()
# Automatically determine device and data_format
# Automatically determine device and data_format
(
device
,
data_format
)
=
(
'/gpu:0'
,
'channels_first'
)
(
device
,
data_format
)
=
(
'/gpu:0'
,
'channels_first'
)
if
flags
.
no_gpu
or
tfe
.
num_gpus
()
<=
0
:
if
flags
.
no_gpu
or
not
tf
.
test
.
is_gpu_available
()
:
(
device
,
data_format
)
=
(
'/cpu:0'
,
'channels_last'
)
(
device
,
data_format
)
=
(
'/cpu:0'
,
'channels_last'
)
# If data_format is defined in FLAGS, overwrite automatically set value.
# If data_format is defined in FLAGS, overwrite automatically set value.
if
flags
.
data_format
is
not
None
:
if
flags
.
data_format
is
not
None
:
...
...
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