【发布时间】:2020-10-15 16:37:44
【问题描述】:
这是我得到的错误: Feed 的值不能是 tf.Tensor 对象。可接受的提要值包括 Python 标量、字符串、列表、numpy ndarray 或 TensorHandles。作为参考,张量对象是 Tensor("x_19:0", shape=(?, 1), dtype=float32) ,它使用键 Tensor("x:0", shape=(?, 1) , dtype=float32)。
这是我的代码:
self.x_tf = tf.placeholder(tf.float32, shape=[None, self.x.shape[1]], name='x')
self.t_tf = tf.placeholder(tf.float32, shape=[None, self.t.shape[1]], name='t')
self.theta = self.net_theta(self.x_tf, self.t_tf)
def net_theta(self, x, t):
new_saver = tf.train.import_meta_graph('__file__theta.ckpt.meta')
new_saver.restore(model.sess,tf.train.latest_checkpoint('./'))
graph = tf.get_default_graph()
x_name = graph.get_tensor_by_name("x:0")
t_name = graph.get_tensor_by_name('t:0')
Pred = graph.get_tensor_by_name('Pred:0')
feed_dict = {x_name:x,t_name: t}
theta = self.sess.run(Pred,feed_dict)
return theta
【问题讨论】:
标签: python tensorflow placeholder