Commit ded78a6
committed
Fix training script on TensorFlow v1.0 and above
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.1 parent 0fc8b4e commit ded78a6
1 file changed
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
| 96 | + | |
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
| |||
0 commit comments