python - TensorFlow; Error in attempting to print out the loss value of CNN model -
i'm trying modify mnist_deep.py, provided tensorflow.org, display loss value. below fragment of code:
print ("\n***** training prediction model... *****\n") print ("model: convolutional neural network, activation: relu + softmax\n") in range(20000): batch_x, batch_y = mnist.train.next_batch(50) sess.run(train_step, feed_dict={x: batch_x, y_: batch_y, keep_prob: 0.5}) [_, avg_cost] = sess.run([train_step, cross_entropy], feed_dict = {x: batch_x, y: batch_y}) if % 100 == 0: train_accuracy = accuracy.eval(feed_dict={x: batch_x, y_: batch_y, keep_prob: 1.0}) if (debugged == true): print("step = %05d, training accuracy = %.2f" % (i, train_accuracy), "average cost = ", avg_cost) else: print("step = %05d, training accuracy = %.2f" % (i, train_accuracy))
the problem line:
[_, avg_cost] = sess.run([train_step, cross_entropy], feed_dict = {x: batch_x, y: batch_y})
it keeps telling me shape [-1, 10] has negative dimensions. i'm new tensorflow, cannot figure out problem is. me track source of problem?
one problem code don't pass value keep_prob
in call sess.run
. passed on line above. unless redundant on line, need on following line well.
if not solve problem, please post or link full version of code reproduce this.
Comments
Post a Comment