stanford-tensorflow-tutorials
stanford-tensorflow-tutorials copied to clipboard
Hotfix mnist sess run
The current example MNIST code has this line in it:
accuracy_batch = sess.run([accuracy], feed_dict={X: X_batch, Y:Y_batch})
This gives error (attempting to add a list to an int):
---> 33 total_correct_preds += accuracy_batch
34 print('Accuracy {0}'.format(total_correct_preds/mnist.test.num_examples))
35
TypeError: unsupported operand type(s) for +: 'int' and 'list'
This hotfix fixes it, by ensuring we are parsing a tensor object (instead of a list of 1 tensor object). i.e.
accuracy_batch = sess.run(accuracy, ...)
Note: Parsing a list is only appropriate when we are parsing multiple tensor objects. i.e. the following would work (and produce no error):
accuracy_batch_a, accuracy_batch_b = sess.run([accuracy, accuracy], ...)