Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/359.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 导出推理图时出错(ValueError)_Python_Tensorflow_Machine Learning - Fatal编程技术网

Python 导出推理图时出错(ValueError)

Python 导出推理图时出错(ValueError),python,tensorflow,machine-learning,Python,Tensorflow,Machine Learning,因此,我正在学习sentdex的对象检测教程,我已经完成了导出推理图的步骤。我正在使用Tensorflow的object\u detection文件夹中的“export\u interference\u graph.py”脚本。 问题是我得到了这个值错误: Traceback (most recent call last): File "C:\Users\Zelcore-Dator\AppData\Local\Programs\Python\Python35\lib\site-package

因此,我正在学习sentdex的对象检测教程,我已经完成了导出推理图的步骤。我正在使用Tensorflow的object\u detection文件夹中的“export\u interference\u graph.py”脚本。 问题是我得到了这个值错误:

Traceback (most recent call last):
  File "C:\Users\Zelcore-Dator\AppData\Local\Programs\Python\Python35\lib\site-packages\google\proto
buf\internal\python_message.py", line 545, in _GetFieldByName
    return message_descriptor.fields_by_name[field_name]
KeyError: 'layout_optimizer'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "export_inference_graph.py", line 119, in <module>
    tf.app.run()
  File "C:\Users\Zelcore-Dator\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\p
ython\platform\app.py", line 48, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File "export_inference_graph.py", line 115, in main
    FLAGS.output_directory, input_shape)
  File "C:\Users\Zelcore-Dator\AppData\Local\Programs\Python\Python35\lib\site-packages\object_detec
tion-0.1-py3.5.egg\object_detection\exporter.py", line 427, in export_inference_graph
    input_shape, optimize_graph, output_collection_name)
  File "C:\Users\Zelcore-Dator\AppData\Local\Programs\Python\Python35\lib\site-packages\object_detec
tion-0.1-py3.5.egg\object_detection\exporter.py", line 391, in _export_inference_graph
    initializer_nodes='')
  File "C:\Users\Zelcore-Dator\AppData\Local\Programs\Python\Python35\lib\site-packages\object_detec
tion-0.1-py3.5.egg\object_detection\exporter.py", line 72, in freeze_graph_with_def_protos
    layout_optimizer=rewriter_config_pb2.RewriterConfig.ON)
  File "C:\Users\Zelcore-Dator\AppData\Local\Programs\Python\Python35\lib\site-packages\google\proto
buf\internal\python_message.py", line 484, in init
    field = _GetFieldByName(message_descriptor, field_name)
  File "C:\Users\Zelcore-Dator\AppData\Local\Programs\Python\Python35\lib\site-packages\google\proto
buf\internal\python_message.py", line 548, in _GetFieldByName
    (message_descriptor.name, field_name))
ValueError: Protocol message RewriterConfig has no "layout_optimizer" field.
回溯(最近一次呼叫最后一次):
文件“C:\Users\Zelcore Dator\AppData\Local\Programs\Python\Python35\lib\site packages\google\proto
buf\internal\python_message.py”,第545行,在_GetFieldByName中
返回消息\u描述符。字段\u按\u名称[字段\u名称]
KeyError:“布局\优化器”
在处理上述异常期间,发生了另一个异常:
回溯(最近一次呼叫最后一次):
文件“export\u expression\u graph.py”,第119行,在
tf.app.run()
文件“C:\Users\Zelcore Dator\AppData\Local\Programs\Python35\lib\site packages\tensorflow\p
“ython\platform\app.py”,第48行,运行中
_系统出口(主(_sys.argv[:1]+标志_passthrough))
文件“export\u expression\u graph.py”,第115行,主目录
FLAGS.output_目录,input_形状)
文件“C:\Users\Zelcore Dator\AppData\Local\Programs\Python35\lib\site packages\object\u detec”
tion-0.1-py3.5.egg\object\u detection\exporter.py”,第427行,在导出推理图中
输入\图形,优化\图形,输出\集合\名称)
文件“C:\Users\Zelcore Dator\AppData\Local\Programs\Python35\lib\site packages\object\u detec”
tion-0.1-py3.5.egg\object\u detection\exporter.py”,第391行,在导出推理图中
初始值设定项_节点=“”)
文件“C:\Users\Zelcore Dator\AppData\Local\Programs\Python35\lib\site packages\object\u detec”
tion-0.1-py3.5.egg\object\u detection\exporter.py”,第72行,在冻结图中,带有
布局\优化器=重写器\配置\ pb2.RewriterConfig.ON)
文件“C:\Users\Zelcore Dator\AppData\Local\Programs\Python\Python35\lib\site packages\google\proto
buf\internal\python_message.py”,第484行,在init中
field=\u GetFieldByName(消息\u描述符,字段\u名称)
文件“C:\Users\Zelcore Dator\AppData\Local\Programs\Python\Python35\lib\site packages\google\proto
buf\internal\python_message.py”,第548行,在_GetFieldByName中
(消息_descriptor.name,字段_name))
ValueError:协议消息RewriterConfig没有“布局\优化器”字段。
我猜它与protobuf有关,但我已经重新安装了好几次,但都没有成功。
所有感激的帮助都发生在我身上。几周前没有。 在修复错误之前,您可以使用仍然有效的早期版本。 替换“object_detection/exporter.py”中的第72行:

layout_optimizer=rewriter_config_pb2.RewriterConfig.ON)
与旧的工作线:

optimize_tensor_layout=True)
我用过:

rewrite_options = rewriter_config_pb2.RewriterConfig(optimize_tensor_layout=True)
但是一直遇到同样的问题,直到我去重播

python setup.py install
从我的“研究”文件夹。然后我就可以让一切正常工作了。

删除优化\u张量\u布局=重写器\u配置\u pb2.RewriterConfig.ON

更改
exporter.py中的第71行

rewrite_options = rewriter_config_pb2.RewriterConfig(optimize_tensor_layout=rewriter_config_pb2.RewriterConfig.ON)
致:


工作正常,但我不知道为什么。正如Craig在下面所说,我也在更改第72行后重新运行install命令,以优化_tensor_layout=true)
rewrite_options = rewriter_config_pb2.RewriterConfig()