【Tensorflow Erro】 TypeError: The value of a feed cannot be a tf.Tensor object.

TypeError: The value of a feed cannot be a tf.Tensor object. Acceptable feed values include Python scalars, strings, lists, numpy ndarrays, or TensorHandles.For reference, the tensor object was Tensor("ExpandDims:0", shape=(1, 28, 28, 1), dtype=float32) which was passed to the feed with key Tensor("input0:0", dtype=float32).

报错feed 不能是一个 tf.Tensor对象,无法执行,报错代码如下:

    if ckpt1 and ckpt1.model_checkpoint_path:
        save.restore(sess, ckpt1.model_checkpoint_path)
        for step in range(10):
            
            print(sess.run(y_pre,feed_dict={x1:img1}))

改为:

    if ckpt1 and ckpt1.model_checkpoint_path:
        save.restore(sess, ckpt1.model_checkpoint_path)
        for step in range(10):
            x_in = sess.run(img1)
            print(sess.run(y_pre,feed_dict={x1:x_in}))

程序正常。

猜你喜欢

转载自blog.csdn.net/qq_34106574/article/details/82687198