愿天堂没有Tensorflow! 阿门。
TypeError: The value of a feed cannot be a tf.Tensor object. Acceptable feed values include Python scalars, strings, lists, or numpy ndarrays.
在训练模型的过程中,我们希望能够给当前训练参数下的网络喂一些测试图片,然后输出当前最后一层的结果。
test_images,test_label = get_batch(test,test_label,IMG_W,IMG_H,BATCH_SIZE,CAPACITY)
if step % 1000 == 0 or (step + 1) == MAX_STEP:
checkpoint_path = os.path.join(logs_train_dir, 'model.ckpt')
saver.save(sess, checkpoint_path, global_step = step)
embed2 = siamese.o1.eval({siamese.x1: test_images})
embed2.tofile('embed.txt')
出现错误
TypeError: The value of a feed cannot be a tf.Tensor object. Acceptable feed values include Python scalars, strings, lists, or numpy ndarrays.
错误原因是这里的test_images 仅仅是tensorflow数据流图上定义好的,实际上它并不是一个实际的数据,仅仅是一个Tensor,feed的必须是实际的数据。实际的数据需要sees run来获得。所以只要在上述代码加上:
test_images = sess.run(test_images)
错误便会消失。