Search code examples
pythontensorflowtensorboard

Viewing Graph from saved .pbtxt file on Tensorboard


I just have a graph.pbtxt file. I want to view the graph in tensorboard. But I am not aware of how to do that. Do I have to write any python script or can I do it from the terminal itself? Kindly help me to know the steps involved.


Solution

  • You can save .pb file from your .pbtxt with tf.train.write_graph

    from google.protobuf import text_format
    
    with open('graph.pbtxt') as f:
        text_graph = f.read()
    graph_def = text_format.Parse(text_graph, tf.GraphDef())
    tf.train.write_graph(graph_def, path, 'graph.pb', as_text=False)
    

    Then you can load it in tf.Session. Take a look at this gist
    https://gist.github.com/jubjamie/2eec49ca1e4f58c5310d72918d991ef6