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
1b71bdbf
"magic_pdf/git@developer.sourcefind.cn:wangsen/mineru.git" did not exist on "d5e30f8da585ba35d1e428d0debbc9ef561c9549"
Unverified
Commit
1b71bdbf
authored
Jan 30, 2018
by
Neal Wu
Committed by
GitHub
Jan 30, 2018
Browse files
Revert "Clear softmax_cross_entropy deprecation warning."
parent
6ab25864
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
11 deletions
+12
-11
official/mnist/dataset.py
official/mnist/dataset.py
+5
-4
official/mnist/mnist.py
official/mnist/mnist.py
+3
-3
official/mnist/mnist_test.py
official/mnist/mnist_test.py
+2
-2
official/mnist/mnist_tpu.py
official/mnist/mnist_tpu.py
+2
-2
No files found.
official/mnist/dataset.py
View file @
1b71bdbf
...
...
@@ -89,14 +89,15 @@ def dataset(directory, images_file, labels_file):
image
=
tf
.
reshape
(
image
,
[
784
])
return
image
/
255.0
def
decode_label
(
label
):
label
=
tf
.
decode_raw
(
label
,
tf
.
uint8
)
# tf.string -> [tf.uint8]
return
tf
.
to_int32
(
label
)
def
one_hot_label
(
label
):
label
=
tf
.
decode_raw
(
label
,
tf
.
uint8
)
# tf.string -> tf.uint8
label
=
tf
.
reshape
(
label
,
[])
# label is a scalar
return
tf
.
one_hot
(
label
,
10
)
images
=
tf
.
data
.
FixedLengthRecordDataset
(
images_file
,
28
*
28
,
header_bytes
=
16
).
map
(
decode_image
)
labels
=
tf
.
data
.
FixedLengthRecordDataset
(
labels_file
,
1
,
header_bytes
=
8
).
map
(
decode
_label
)
labels_file
,
1
,
header_bytes
=
8
).
map
(
one_hot
_label
)
return
tf
.
data
.
Dataset
.
zip
((
images
,
labels
))
...
...
official/mnist/mnist.py
View file @
1b71bdbf
...
...
@@ -102,9 +102,9 @@ def model_fn(features, labels, mode, params):
optimizer
=
tf
.
contrib
.
estimator
.
TowerOptimizer
(
optimizer
)
logits
=
model
(
image
,
training
=
True
)
loss
=
tf
.
losses
.
sparse_
softmax_cross_entropy
(
labels
=
labels
,
logits
=
logits
)
loss
=
tf
.
losses
.
softmax_cross_entropy
(
onehot_
labels
=
labels
,
logits
=
logits
)
accuracy
=
tf
.
metrics
.
accuracy
(
labels
=
labels
,
predictions
=
tf
.
argmax
(
logits
,
axis
=
1
))
labels
=
tf
.
argmax
(
labels
,
axis
=
1
)
,
predictions
=
tf
.
argmax
(
logits
,
axis
=
1
))
# Name the accuracy tensor 'train_accuracy' to demonstrate the
# LoggingTensorHook.
tf
.
identity
(
accuracy
[
1
],
name
=
'train_accuracy'
)
...
...
@@ -115,7 +115,7 @@ def model_fn(features, labels, mode, params):
train_op
=
optimizer
.
minimize
(
loss
,
tf
.
train
.
get_or_create_global_step
()))
if
mode
==
tf
.
estimator
.
ModeKeys
.
EVAL
:
logits
=
model
(
image
,
training
=
False
)
loss
=
tf
.
losses
.
sparse_
softmax_cross_entropy
(
labels
=
labels
,
logits
=
logits
)
loss
=
tf
.
losses
.
softmax_cross_entropy
(
onehot_
labels
=
labels
,
logits
=
logits
)
return
tf
.
estimator
.
EstimatorSpec
(
mode
=
tf
.
estimator
.
ModeKeys
.
EVAL
,
loss
=
loss
,
...
...
official/mnist/mnist_test.py
View file @
1b71bdbf
...
...
@@ -27,8 +27,8 @@ BATCH_SIZE = 100
def
dummy_input_fn
():
image
=
tf
.
random_uniform
([
BATCH_SIZE
,
784
])
labels
=
tf
.
random_uniform
([
BATCH_SIZE
,
1
],
maxval
=
9
,
dtype
=
tf
.
int32
)
return
image
,
labels
labels
=
tf
.
random_uniform
([
BATCH_SIZE
],
maxval
=
9
,
dtype
=
tf
.
int32
)
return
image
,
tf
.
one_hot
(
labels
,
10
)
def
make_estimator
():
...
...
official/mnist/mnist_tpu.py
View file @
1b71bdbf
...
...
@@ -50,7 +50,7 @@ FLAGS = tf.flags.FLAGS
def
metric_fn
(
labels
,
logits
):
accuracy
=
tf
.
metrics
.
accuracy
(
labels
=
labels
,
predictions
=
tf
.
argmax
(
logits
,
axis
=
1
))
labels
=
tf
.
argmax
(
labels
,
axis
=
1
)
,
predictions
=
tf
.
argmax
(
logits
,
axis
=
1
))
return
{
"accuracy"
:
accuracy
}
...
...
@@ -64,7 +64,7 @@ def model_fn(features, labels, mode, params):
model
=
mnist
.
Model
(
"channels_last"
)
logits
=
model
(
image
,
training
=
(
mode
==
tf
.
estimator
.
ModeKeys
.
TRAIN
))
loss
=
tf
.
losses
.
sparse_
softmax_cross_entropy
(
labels
=
labels
,
logits
=
logits
)
loss
=
tf
.
losses
.
softmax_cross_entropy
(
onehot_
labels
=
labels
,
logits
=
logits
)
if
mode
==
tf
.
estimator
.
ModeKeys
.
TRAIN
:
learning_rate
=
tf
.
train
.
exponential_decay
(
...
...
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