首页 > 解决方案 > 使用 feed_dict 在 retrain.py 中进行预测的全局名称错误

问题描述

我运行代码

  with tf.Session() as sess:
    print(sess.run(tf.argmax(final_tensor, 1), feed_dict={resized_input_tensor: create_image_lists(testing_images)}))

在 retrain.py 中(我也尝试过在 feed_dict 中没有 create_image_lists 的代码)在 final_tensor 设置之后(第 776 行是我的代码插入的位置)并收到错误

NameError: global name 'testing_images' is not defined

在 feed_dict 中使用了测试图像,因为据我了解,它是一个数组,所有图像都存储为某种形状,然后它将成为 final_tensor 操作的输入。如果这是真的,那么我需要找到一种在 feed_dict 中输入的方法。

标签: pythontensorflowglobal-variablesprediction

解决方案


推荐阅读