如何使用 Tensorflow 的 Python 程序和 Tensorflow 的检查点文件(从此处下载)为 Inception-ResNet-v2 制作预训练/冻结图?
下面显示了我尝试过的,但freeze_graph.py
似乎没有找到变量。
是否缺少另一个步骤?
图表和检查点中的变量名称是否不兼容?
$ python3 $TENSORFLOW_HOME/models/research/slim/export_inference_graph.py \
--modal_name inception_resnet_v2 \
--output_file /tmp/inception_resnet_v2.pb
2018-01-08 02:35:11.819267: I tensorflow/core/platform/s3/aws_logging.cc:53] Initializing Curl library
/usr/lib64/python3.6/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
from ._conv import register_converters as _register_converters
INFO:tensorflow:Scale of 0 disables regularizer.
$ python3 $TENSORFLOW_HOME/tensorflow/tensorflow/python/tools/freeze_graph.py \
--input_graph /tmp/inception_resnet_v2.pb \
--input_checkpoint /tmp/inception_resnet_v2_2016_08_30.ckpt \
--output_graph /tmp/inception_resnet_v2-frozen_graph.pb \
--input_binary true \
--output_node_names 'InceptionV3/Predictions/Reshape_1'
2018-01-08 02:36:23.083874: I tensorflow/core/platform/s3/aws_logging.cc:53] Initializing Curl library
/usr/lib64/python3.6/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
from ._conv import register_converters as _register_converters
Traceback (most recent call last):
File "/usr/local/src/tensorflow/tensorflow/tensorflow/python/tools/freeze_graph.py", line 350, in <module>
app.run(main=main, argv=[sys.argv[0]] + unparsed)
File "/home/rick/.local/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 124, in run
_sys.exit(main(argv))
File "/usr/local/src/tensorflow/tensorflow/tensorflow/python/tools/freeze_graph.py", line 249, in main
FLAGS.saved_model_tags)
File "/usr/local/src/tensorflow/tensorflow/tensorflow/python/tools/freeze_graph.py", line 239, in freeze_graph
input_meta_graph_def, input_saved_model_dir, saved_model_tags.split(","))
File "/usr/local/src/tensorflow/tensorflow/tensorflow/python/tools/freeze_graph.py", line 127, in freeze_graph_with_def_protos
saver = saver_lib.Saver(var_list=var_list)
File "/home/rick/.local/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1288, in __init__
self.build()
File "/home/rick/.local/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1297, in build
self._build(self._filename, build_save=True, build_restore=True)
File "/home/rick/.local/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1322, in _build
raise ValueError("No variables to save")
ValueError: No variables to save