Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix training script on TensorFlow r1.0+ (ValueError: softmax_cross_entropy_with_logits) #2

Merged

Conversation

daj
Copy link
Contributor

@daj daj commented Sep 4, 2017

Though this script works fine on r0.11, on r1.0 and above you hit this error (I tested on r1.0, r1.2 and r1.3):

# python mnist.py
Extracting MNIST_data/train-images-idx3-ubyte.gz
Extracting MNIST_data/train-labels-idx1-ubyte.gz
Extracting MNIST_data/t10k-images-idx3-ubyte.gz
Extracting MNIST_data/t10k-labels-idx1-ubyte.gz
Traceback (most recent call last):
  File "mnist.py", line 96, in <module>
    cost = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(pred, y))
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/nn_ops.py", line 1558, in softmax_cross_entropy_with_logits
    labels, logits)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/nn_ops.py", line 1512, in _ensure_xent_args
    "named arguments (labels=..., logits=..., ...)" % name)
ValueError: Only call `softmax_cross_entropy_with_logits` with named arguments (labels=..., logits=..., ...)

Implemented fix as described here: https://stackoverflow.com/a/42297021/112705

TESTING

After the change, I tested on TensorFlow r0.11 and r1.3, and the script runs successfully.

Though the script works fine on r0.11, on r1.0 and above you hit this error (I tested on r1.0, r1.2 and r1.3):
```
# python mnist.py
Extracting MNIST_data/train-images-idx3-ubyte.gz
Extracting MNIST_data/train-labels-idx1-ubyte.gz
Extracting MNIST_data/t10k-images-idx3-ubyte.gz
Extracting MNIST_data/t10k-labels-idx1-ubyte.gz
Traceback (most recent call last):
  File "mnist.py", line 96, in <module>
    cost = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(pred, y))
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/nn_ops.py", line 1558, in softmax_cross_entropy_with_logits
    labels, logits)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/nn_ops.py", line 1512, in _ensure_xent_args
    "named arguments (labels=..., logits=..., ...)" % name)
ValueError: Only call `softmax_cross_entropy_with_logits` with named arguments (labels=..., logits=..., ...)
```
Implemented fix as described here: https://stackoverflow.com/a/42297021/112705

TESTING

After the change, I tested on TensorFlow r0.11 and r1.3, and the script runs successfully.
@amitshekhariitbhu amitshekhariitbhu merged commit 4d0b1ea into amitshekhariitbhu:master Sep 5, 2017
@daj daj deleted the fix-training-script branch October 9, 2017 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants