I can get inputs and outputs of graph by using summarize_graph tool, like:
bazel-bin/tensorflow/tools/graph_transforms/summarize_graph --in_graph="inception_v3_2016_08_28_frozen.pb"
Which gives me:
Found 1 possible inputs: (name=input, type=float(1), shape=None)
No variables spotted.
Found 1 possible outputs: (name=InceptionV3/Predictions/Reshape_1, op=Reshape)
Found 23853946 (23.85M) const parameters, 0 (0) variable parameters, and 0 control_edges
Op types used: 489 Const, 188 Mul, 188 Add, 95 Conv2D, 94 Sub, 94 Relu, 94 Rsqrt, 15 ConcatV2, 10 AvgPool, 4 MaxPool, 2 Reshape, 1 BiasAdd, 1 Softmax, 1 Squeeze, 1 Placeholder
Is it possible to get inputs and outputs names of arbitrary .pb model in python?
Here is only solution for inputs:
with tf.gfile.GFile(input_model_filepath, "rb") as f:
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
with tf.Graph().as_default() as graph:
tf.import_graph_def(graph_def, name='')
for op in graph.get_operations():
if op.type == "Placeholder":
print(op.name)
Not sure if inputs are always should be Placeholder type.