愿天堂沒有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)
錯誤便會消失。