我正在使用tensorflow-1.13创建一个deep-q模型,并使用以下代码保存它。
tf.global_variables_initializer()
tf.local_variables_initializer()
saver = tf.train.Saver()
saver.save(tf.get_default_session(), 'deepq_0519')
我有以下文件:
checkpoint
deepq_0519.data-00000-of-00001
deepq_0519.index
deepq_0519.meta
我还使用下面的代码保存图表:
tf.train.write_graph(sess.graph_def, '.', 'deepq_0519.pbtxt')
得到:
deepq_0519.pbtxt
最后,我尝试使用保存的文件创建冻结图形:
from tensorflow.python.tools import freeze_graph
freeze_graph.freeze_graph('deepq_0519.pbtxt', "", False,
'deepq_0519.data-00000-of-00001',"deepq/cond/Merge",
"", "",
'deepq_0519_frozen.pb', True, ""
)
但出现了以下错误。知道我做错了什么吗?谢谢!
WARNING:tensorflow:From /Users/edamame/workspace/git/my_proj/venv/lib/python3.6/site-packages/tensorflow/python/tools/freeze_graph.py:249: FastGFile.__init__ (from tensorflow.python.platform.gfile) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.gfile.GFile.
WARNING:tensorflow:From /Users/edamame/workspace/git/my_project/venv/lib/python3.6/site-packages/tensorflow/python/tools/freeze_graph.py:127: checkpoint_exists (from tensorflow.python.training.checkpoint_management) is deprecated and will be removed in a future version.
Instructions for updating:
Use standard file APIs to check for files with this prefix.
2019-05-19 16:00:06.642801: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2019-05-19 16:00:06.646182: W tensorflow/core/util/tensor_slice_reader.cc:95] Could not open ./deepq_0519.data-00000-of-00001: Data loss: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?
Traceback (most recent call last):
File "my_freeze.py", line 6, in <module>
'deepq_0519_frozen.pb', True, ""
File "/Users/edamame/workspace/git/my_proj/venv/lib/python3.6/site-packages/tensorflow/python/tools/freeze_graph.py", line 363, in freeze_graph
checkpoint_version=checkpoint_version)
File "/Users/edamame/workspace/git/my_proj/venv/lib/python3.6/site-packages/tensorflow/python/tools/freeze_graph.py", line 164, in freeze_graph_with_def_protos
reader = pywrap_tensorflow.NewCheckpointReader(input_checkpoint)
File "/Users/edamame/workspace/git/my_proj/venv/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 326, in NewCheckpointReader
return CheckpointReader(compat.as_bytes(filepattern), status)
File "/Users/edamame/workspace/git/my_proj/venv/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py", line 528, in __exit__
c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.DataLossError: Unable to open table file ./deepq_0519.data-00000-of-00001: Data loss: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?