Skip to content Skip to sidebar Skip to footer

Tensorflow: Feed Dict Error: You Must Feed A Value For Placeholder Tensor

I have one bug I cannot find out the reason. Here is the code: with tf.Graph().as_default(): global_step = tf.Variable(0, trainable=False) images = tf.placeholder(

Solution 1:

When I try to comment the code summary_op = tf.merge_all_summaries() and the code works fine. why is it the case?

summary_op is an operation. If there exists (and this is true in your case) a summary operation related to the result of another operation that depends upon the values of the placeholders, you have to feed the graph the required values.

So, your line summary_str = sess.run(summary_op) needs the dictionary of the values to store.

Usually, instead of re-executing the operations to log the values, you run the operations and the summary_op once.

Do something like

ifstep%LOGGING_TIME_STEP==0:_,loss_value,summary_str=sess.run([train_op,losses,summary_op],feed_dict={images:data_batch,labels:label_batch})else:_,loss_value=sess.run([train_op,losses],feed_dict={images:data_batch,labels:label_batch})

Post a Comment for "Tensorflow: Feed Dict Error: You Must Feed A Value For Placeholder Tensor"