stanford-tensorflow-tutorials icon indicating copy to clipboard operation
stanford-tensorflow-tutorials copied to clipboard

03_logistic_regression_mnist, line 81, TypeError:

Open jerinw opened this issue 8 years ago • 2 comments
trafficstars

could someone tell me how to deal with it.

Traceback (most recent call last): File "C:/Users/Jerin/PycharmProjects/pyflow/main.py", line 81, in total_correct_preds += accuracy_batch TypeError: unsupported operand type(s) for +=: 'int' and 'list'

jerinw avatar Sep 05 '17 05:09 jerinw

if you see the print accuracy_batch, you'll notice it is list. You should flatten to have the float number to add up.

total_correct_preds += accuracy_batch[0]

will work.

physhik avatar Sep 30 '17 22:09 physhik

I have created a Pull Request #85 to fix this issue. I have explained what is happening in the Pull Request.

In a nutshell, the line (returns a list of 1 value):

accuracy_batch = sess.run([accuracy], ...) 

needs to be changed to (returns a scalar):

accuracy_batch = sess.run(accuracy, ...)

Atlas7 avatar Jan 03 '18 16:01 Atlas7