Search code examples
ctensorflowdeep-learningc-api

How to find out the correct input and output operation of a frozen tensorflow graph?


I received a neural network trained in python, the format is frozen graph (.pb). In order to do the inference using the C-API (which is required for this special case) I need to find out the name of the input and output operation of the graph. Obviously the names are different from those during the training. The graph has 1780 operations, the following contain "input" or "output" in their name:

input:

bn1a_branch2a/keras_learning_phase/input

input_1_7



output:

output_1/kernel

output_1/bias

output_1_1/kernel

output_1_1/bias

output_1_2/kernel

output_1_2/bias

output_1_3/kernel

output_1_3/bias

output_1_4/kernel

output_1_4/bias

output_1_5/kernel

output_1_5/bias

output_1_6/kernel

output_1_6/bias

output_1_7/kernel

output_1_7/kernel/read

output_1_7/bias

output_1_7/bias/read

output_1_7/MatMul

output_1_7/BiasAdd

Is there a way to find out the actual input and output operation of the frozen graph?


Solution

  • Ok for anyone looking for an answer: the only reliable way seems to be visualizing the graph using Tensorboard. By that you can avoid any pitfalls, no matter how many operations your graph includes.