List of tensor names in graph in Tensorflow

List of tensor names in graph in Tensorflow

Asked on December 17, 2018 in Tensorflow.
Add Comment


  • 1 Answer(s)

    Try this code to print the tensor names in a graph:

    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")
    
    Answered on December 17, 2018.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.