愿天堂沒(méi)有Tensorflow默蚌! 阿門鸭限。
TypeError: The value of a feed cannot be a tf.Tensor object. Acceptable feed values include Python scalars, strings, lists, or numpy ndarrays.
在訓(xùn)練模型的過(guò)程中泻帮,我們希望能夠給當(dāng)前訓(xùn)練參數(shù)下的網(wǎng)絡(luò)喂一些測(cè)試圖片悠抹,然后輸出當(dāng)前最后一層的結(jié)果夭织。
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')
出現(xiàn)錯(cuò)誤
TypeError: The value of a feed cannot be a tf.Tensor object. Acceptable feed values include Python scalars, strings, lists, or numpy ndarrays.
錯(cuò)誤原因是這里的test_images 僅僅是tensorflow數(shù)據(jù)流圖上定義好的网杆,實(shí)際上它并不是一個(gè)實(shí)際的數(shù)據(jù)吃环,僅僅是一個(gè)Tensor也颤,feed的必須是實(shí)際的數(shù)據(jù)。實(shí)際的數(shù)據(jù)需要sees run來(lái)獲得郁轻。所以只要在上述代碼加上:
test_images = sess.run(test_images)
錯(cuò)誤便會(huì)消失翅娶。