I am a newer for tensorflow, and I am confused with the graph struction in tensorflow tutorial label_image . Using the code blew:
import tensorflow as tf
with tf.Session() as sess:
with open('/var/tmp/feng/tensorflow/tensorflow/examples/label_image/data/inception_v3_2016_08_28_frozen.pb', 'rb') as f:
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
print graph_def
I can see the graph struction as this
...
...
node {
name: "InceptionV3/Predictions/Reshape_1"
op: "Reshape"
input: "InceptionV3/Predictions/Softmax"
input: "InceptionV3/Predictions/Shape"
attr {
key: "T"
value {
type: DT_FLOAT
}
}
attr {
key: "Tshape"
value {
type: DT_INT32
}
}
}
It's OK. I can see the last node name is "InceptionV3/Predictions/Reshape_1",however, when I use code blew to show all operations
the operation in this graph
with tf.Session(graph=graph) as sess:
# results = sess.run(output_tensor, {
# input_tensor: t
# })
print(sess.graph.get_operations())
It shows me like this
<tf.Operation 'import/InceptionV3/Predictions/Softmax' type=Softmax>,
<tf.Operation 'import/InceptionV3/Predictions/Shape' type=Const>,
<tf.Operation 'import/InceptionV3/Predictions/Reshape_1' type=Reshape>
why the operation name add import before the node name.It's strange because the string import never appears in the graph of this model.I google it but everyone says the function
get_operation_by_name
return an instance of type tf.Operation,which is a node in the computational graph, so the difference between operation name and node name is confused. Can anyone help me ?