Skip to content

Instantly share code, notes, and snippets.

@kvablack
Created October 5, 2020 21:16
Show Gist options
  • Save kvablack/f148da3a07572dcc73653ad73e943542 to your computer and use it in GitHub Desktop.
Save kvablack/f148da3a07572dcc73653ad73e943542 to your computer and use it in GitHub Desktop.
Tensorflow 2 code to dump a SavedModel graph to Tensorboard format as well as text format
import tensorflow as tf
import sys
if __name__ == '__main__':
graph = tf.saved_model.load(sys.argv[1]).signatures['serving_default'].graph
with graph.as_default():
writer = tf.compat.v1.summary.FileWriter(sys.argv[2])
writer.add_graph(graph)
writer.close()
tf.io.write_graph(graph.as_graph_def(), sys.argv[2], "graph.pbtxt")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment