Tensorflow诗人label_image问题

时间:2019-03-07 17:16:00

标签: python python-3.x tensorflow input

我正在尝试进行Tensorflow for Poets教程,而我正在使用重新训练模型的第6步。我正在尝试运行以下命令:

python -m scripts.label_image --graph=tf_files/retrained_graph.pb -- image=tf_files/flower_photos/daisy/21652746_cc379e0eea_m.jpg

并返回此错误:

2019-03-06 16:13:27.270248: I Tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
Traceback (most recent call last):
File "C:\Users\rzara\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
 File "C:\Users\rzara\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\rzara\Documents\GitHub\tensorflow-for-poets- 2\scripts\label_image.py", line 121, in <module>
input_operation = graph.get_operation_by_name(input_name);
File "C:\Users\rzara\AppData\Local\Programs\Python\Python37\lib\site- packages\tensorflow\python\framework\ops.py", line 3606, in get_operation_by_name
return self.as_graph_element(name, allow_tensor=False, allow_operation=True)
File "C:\Users\rzara\AppData\Local\Programs\Python\Python37\lib\site- packages\tensorflow\python\framework\ops.py", line 3478, in as_graph_element
return self._as_graph_element_locked(obj, allow_tensor, allow_operation)
File "C:\Users\rzara\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\framework\ops.py", line 3538, in 
_as_graph_element_locked
"graph." % repr(name))
**KeyError: "The name 'import/Mul' refers to an Operation not in the graph."**

我已经尝试打开label_image.py并进行更改:

input_height = 299
input_width = 299
input_layer = 'Mul'

,但仍然无法运行。请帮忙。我已经检查了此处的另一篇文章,但没有帮助:tensorflow for poets: "The name 'import/input' refers to an Operation not in the graph."

1 个答案:

答案 0 :(得分:0)

很显然,该层是错误的,查看了official github并在其中使用了“输入”名称,也许可行。如果这不起作用,则需要加载模型并检查张量板图,如果您按照教程进行操作,则很可能已经完成了。从图中应该可以清楚地看到您的输入张量是第一个。如果它不起作用,请告诉我