获取" TypeError:names_to_saveables必须是字符串映射到Tensors / Variables的字符串名称。不是变量"何时使用freeze_graph

时间:2018-04-02 07:54:37

标签: tensorflow

我试图冻结使用 LinearClassifier 训练的图表。该代码几乎与 TensorFlow 中的wide_deep教程相匹配。培训成功完成,估算工作非常顺利(100%成功)。不幸的是,当我试图冻结图表以便将其移植到移动设备上时,我收到错误:

TypeError: names_to_saveables must be a dict mapping string names to Tensors/Variables. Not a variable: Tensor("linear/linear_model/0/weights:0", shape=(1, 14), dtype=float32)

命令是:

python freeze_graph.py --input_graph=/media/LinuxApps/Documents/FFTTestData/fft_piano_model/graph.pbtxt --input_checkpoint=/media/LinuxApps/Documents/FFTTestData/fft_piano_model/model.ckpt-190 output_graph=/media/LinuxApps/Documents/FFTTestData/fft_piano_model/frozen_graph.pb --output_node_names=softmax

Stacktrace是:

Traceback (most recent call last):
  File "freeze_graph.py", line 380, in <module>
app.run(main=main, argv=[sys.argv[0]] + unparsed)
  File "/media/LinuxApps/home/karsten/.local/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 126, in run
_sys.exit(main(argv))
  File "freeze_graph.py", line 274, in main
FLAGS.saved_model_tags, checkpoint_version)
  File "freeze_graph.py", line 256, in freeze_graph
checkpoint_version=checkpoint_version)
  File "freeze_graph.py", line 130, in freeze_graph_with_def_protos
var_list=var_list, write_version=checkpoint_version)
  File "/media/LinuxApps/home/karsten/.local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1293, in __init__
self.build()
  File "/media/LinuxApps/home/karsten/.local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1302, in build
self._build(self._filename, build_save=True, build_restore=True)
  File "/media/LinuxApps/home/karsten/.local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1339, in _build
build_save=build_save, build_restore=build_restore)
  File "/media/LinuxApps/home/karsten/.local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 774, in _build_internal
saveables = self._ValidateAndSliceInputs(names_to_saveables)
  File "/media/LinuxApps/home/karsten/.local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 677, in _ValidateAndSliceInputs
variable)
TypeError: names_to_saveables must be a dict mapping string names to Tensors/Variables. Not a variable: Tensor("linear/linear_model/0/weights:0", shape=(1, 14), dtype=float32)

有人可以帮忙吗?

谢谢!

0 个答案:

没有答案