Reputation: 183
It will report TypeError: The value of a feed cannot be a tf.Tensor object. Acceptable feed values include Python scalars, strings, lists, or numpy ndarrays. when run my tensorflow code Is there some bug below my code? I have convert tensor type by using feed_dict types.Why it still failed?
with tf.Session() as sess:
tf.initialize_all_variables().run()
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(coord=coord)
print('Initialized!')
for step in xrange(150000):
data,label = read_data(FLAGS.train_file)
feed_dict = {train_data_node: data,
train_labels_node: label}
_, l, lr, predictions = sess.run([optimizer, loss_value, learning_rate, train_prediction],feed_dict=feed_dict)
Upvotes: 1
Views: 1273
Reputation: 27042
The error says: The value of a feed cannot be a tf.Tensor
Your feed is:
feed_dict = {train_data_node: data,
train_labels_node: label}
Thus, one (or both) between data
& label
are tf.Tensor
object.
You have to extract the value into this object, obtaining an acceptable value for a feed.
To do this, you have to run
(or eval
) the object before passing it to the feed.
Tl;dr:
feed_dict = {train_data_node: data.eval(),
train_labels_node: label.eval()}
Upvotes: 1