Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. def show_graph_details(graph, mark):
  2. import tensorflow as tf
  3. import pprint
  4. if isinstance(graph, tf.GraphDef):
  5. with tf.Session(graph=tf.Graph()) as sess:
  6. tf.import_graph_def(graph)
  7. graph = sess.graph
  8. elif isinstance(graph, tf.MetaGraphDef):
  9. with tf.Session(graph=tf.Graph()) as sess:
  10. tf.import_graph_def(graph.graph_def)
  11. graph = sess.graph
  12.  
  13. print('[%s] Collections: %s' % (mark, graph.get_all_collection_keys()))
  14. for col in graph.get_all_collection_keys():
  15. print(' %s: %s' % (col, graph.get_collection(col)))
  16.  
  17. print('')
  18. print('[%s] Graph Nodes: %s' % (
  19. mark,
  20. pprint.pformat([n.name for n in graph.as_graph_def().node])))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement