The graph object in Tensorflow has a method called "get_tensor_by_name(name)". Is there anyway to get a list of valid tensor names?
If not, does anyone know the valid names for the pretrained model inception-v3 from here? From their example, pool_3, is one valid tensor but a list of all of them would be nice. I looked at the paper referred to and some of the layers seems to correspond to the sizes in table 1 but not all of them.
Finally, we close the TensorFlow session to release the TensorFlow resources we used within the session. That is how you can get a TensorFlow tensor by name using the tf. get_default_graph operation and then the TensorFlow get_tensor_by_name operation.
Visualization of a TensorFlow graph. To see your own graph, run TensorBoard pointing it to the log directory of the job, click on the graph tab on the top pane and select the appropriate run using the menu at the upper left corner.
Graphs are data structures that contain a set of tf. Operation objects, which represent units of computation; and tf. Tensor objects, which represent the units of data that flow between operations. They are defined in a tf. Graph context.
Returns the default graph for the current thread.
The paper is not accurately reflecting the model. If you download the source from arxiv it has an accurate model description as model.txt, and the names in there correlate strongly with the names in the released model.
To answer your first question, sess.graph.get_operations()
gives you a list of operations. For an op, op.name
gives you the name and op.values()
gives you a list of tensors it produces (in the inception-v3 model, all tensor names are the op name with a ":0" appended to it, so pool_3:0
is the tensor produced by the final pooling op.)
The above answers are correct. I came across an easy to understand / simple code for the above task. So sharing it here :-
import tensorflow as tf def printTensors(pb_file): # read pb into graph_def with tf.gfile.GFile(pb_file, "rb") as f: graph_def = tf.GraphDef() graph_def.ParseFromString(f.read()) # import graph_def with tf.Graph().as_default() as graph: tf.import_graph_def(graph_def) # print operations for op in graph.get_operations(): print(op.name) printTensors("path-to-my-pbfile.pb")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With