I am currently trying to export a trained TensorFlow model as a ProtoBuf file to use it with the TensorFlow C++ API on Android. Therefore, I'm using the freeze_graph.py
script.
I exported my model using tf.train.write_graph
:
tf.train.write_graph(graph_def, FLAGS.save_path, out_name, as_text=True)
and I'm using a checkpoint saved with tf.train.Saver
.
I invoke freeze_graph.py
as described at the top of the script. After compiling, I run
bazel-bin/tensorflow/python/tools/freeze_graph \
--input_graph=<path_to_protobuf_file> \
--input_checkpoint=<model_name>.ckpt-10000 \
--output_graph=<output_protobuf_file_path> \
--output_node_names=dropout/mul_1
This gives me the following error message:
TypeError: Cannot interpret feed_dict key as Tensor: The name 'save/Const:0' refers to a Tensor which does not exist. The operation, 'save/Const', does not exist in the graph.
As the error states I do not have a tensor save/Const:0
in my exported model. However, the code of freeze_graph.py
says that one can specify this tensor name by the flag filename_tensor_name
. Unfortunately I cannot find any information on what this tensor should be and how to set it correctly for my model.
Can somebody tell my either how to produce a save/Const:0
tensor in my exported ProtoBuf model or how to set the flag filename_tensor_name
correctly?