我向feed_dict提供了一个numpy数组,但它仍然给出了这个错误,即feed需要是一个tf.Tensor对象。
index = tf.placeholder(tf.int32, shape=[None], name='index')
dontknow = np.random.choice(range(1,200), 180)
_, summary = sess.run([train, merged], feed_dict={
input_placeholder:train_batch_x,
attr_placeholder:train_class_attr,
label_placeholder:train_batch_y,
index:dontknow
})
这是张量流库中的一个错误,因为我想发布一个问题,但不确定。任何帮助都非常感谢。 感谢
答案 0 :(得分:0)
我认为您的问题不在于dontknow
变量,而在于其中一个:
input_placeholder:train_batch_x,
attr_placeholder:train_class_attr,
label_placeholder:train_batch_y,
当我删除它们时,我可以毫无错误地执行你的东西:
import tensorflow as tf
import numpy as np
index = tf.placeholder(tf.int32, shape=[None], name='index')
dontknow = np.random.choice(range(1,200), 180)
with tf.Session() as sess:
print sess.run(index, {index:dontknow})
在执行sess.run
之前打印每一个,以找出哪个是张量