我是张力流的初学者。我想量化已经训练过的初始模型。我按照步骤运行以下代码:
python -m tensorflow.python.tools.optimize_for_inference \
--input=tf_files/retrained_graph.pb \
--output=tf_files/optimized_graph.pb \
--input_names="input" \
--output_names="final_result"
但我收到错误:
Traceback (most recent call last):
File "C:\Users\Student\Anaconda3\lib\runpy.py", line 193, in _run_module_as_ma
in
"__main__", mod_spec)
File "C:\Users\Student\Anaconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\Student\Anaconda3\lib\site-packages\tensorflow\python\tools\opt
imize_for_inference.py", line 146, in <module>
app.run(main=main, argv=[sys.argv[0]] + unparsed)
File "C:\Users\Student\Anaconda3\lib\site-packages\tensorflow\python\platform\
app.py", line 126, in run
_sys.exit(main(argv))
File "C:\Users\Student\Anaconda3\lib\site-packages\tensorflow\python\tools\opt
imize_for_inference.py", line 90, in main
FLAGS.output_names.split(","), FLAGS.placeholder_type_enum)
File "C:\Users\Student\Anaconda3\lib\site-packages\tensorflow\python\tools\opt
imize_for_inference_lib.py", line 109, in optimize_for_inference
placeholder_type_enum)
File "C:\Users\Student\Anaconda3\lib\site-packages\tensorflow\python\tools\str
ip_unused_lib.py", line 83, in strip_unused
raise KeyError("The following input nodes were not found: %s\n" % not_found)
KeyError: "The following input nodes were not found: {'input'}\n"
请有人帮我解决此问题。
答案 0 :(得分:0)
更改
--input_names="input"
到
--input_names="Mul"
或者如果您在Windows上,只需在终端中从当前工作区运行以下内容
python -m tensorflow.python.tools.optimize_for_inference --input
retrained_graph.pb --output optimized_graph.pb --input_names="Mul" --
output_names="final_result"