Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tensorflow view graph from model.ckpt.meta file

I have a model.ckpt.meta file and I just want to view the architecture/graph structure. I can't find how to do this from the model.ckpt.meta file.

Following the code thanks to Milan:

tf.train.import_meta_graph("./model.ckpt.meta")
for n in tf.get_default_graph().as_graph_def().node:
   print(n)
with tf.Session() as sess:
  writer = tf.summary.FileWriter("./output/", sess.graph)
  writer.close()

I get the graph below. But a lot of the architecture is missing. enter image description here

EDIT: Woops! I forgot to double click the model. Sorted.

like image 258
piccolo Avatar asked Sep 15 '25 03:09

piccolo


1 Answers

You can import the meta graph in python with tf.train.import_meta_graph and then traverse the nodes in the graph, for example:

import tensorflow as tf

tf.train.import_meta_graph("./model.ckpt-200000.meta")
for n in tf.get_default_graph().as_graph_def().node:
   print(n)

Once imported, you can make a summary file for Tensorboard, which allows you to visualize the graph nicely:

with tf.Session() as sess:
  writer = tf.summary.FileWriter("./output/", sess.graph)
  writer.close()

To see the saved summary file in Tensorboard, run tensorboard --logdir=./output/

like image 114
Milan Avatar answered Sep 17 '25 18:09

Milan