1

Code: https://github.com/tensorflow/tensorflow/blob/r0.10/tensorflow/examples/tutorials/mnist/mnist_softmax.py

I want to be able to see/print/display tensor content ( tensor y, - (image, trained label) i.e. x, y pairs for each batch ), as well as the final result.

For example in:

for i in range(1000):

batch_xs, batch_ys = mnist.train.next_batch(100)

train_step.run({x: batch_xs, y_: batch_ys})

# here should be a line to print/eval/sess.run learned x, y pair

  • None of cases in existing print tensor value thread quoted above is a close match. The problem was how to print/see tensor value that is fed via placeholder. That requires special syntax which I had a problem with. Steven below has great answer. – Ranko Mosic Sep 07 '16 at 12:53
  • Question was actually similar to this: http://stackoverflow.com/questions/33711556/making-predictions-with-a-tensorflow-model?rq=1 – Ranko Mosic Sep 10 '16 at 16:19

1 Answers1

1

You're looking for something like

print(sess.run([y],feed_dict={x: batch_xs, y_: batch_ys}))

This will print out y. You can also store the variable and then interact with it as you would a numpy array.

y_val = sess.run([y],feed_dict={x: batch_xs, y_: batch_ys})

Note you should change the name to y_val instead of y as setting y = sess.run([y]...) will overwrite the tensorflow variable y and crash the second time around.

Steven
  • 5,134
  • 2
  • 27
  • 38