欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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

程序员文章站 2024-01-03 19:42:04
...

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).
【Tensorflow Erro】 TypeError: The value of a feed cannot be a tf.Tensor object.

报错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}))

程序正常。

上一篇:

下一篇: