Skip to content

Instantly share code, notes, and snippets.

@albb762
Created December 6, 2018 08:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save albb762/25186114fd81e3344b96df8f5329a153 to your computer and use it in GitHub Desktop.
Save albb762/25186114fd81e3344b96df8f5329a153 to your computer and use it in GitHub Desktop.
#tensorflow#debug#metadata
import tensorflow as tf
from tensorflow.python.client import timeline
a = tf.random_normal([2000, 5000])
b = tf.random_normal([5000, 1000])
res = tf.matmul(a, b)
with tf.Session() as sess:
# add additional options to trace the session execution
options = tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE)
run_metadata = tf.RunMetadata()
sess.run(res, options=options, run_metadata=run_metadata)
# Create the Timeline object, and write it to a json file
fetched_timeline = timeline.Timeline(run_metadata.step_stats)
chrome_trace = fetched_timeline.generate_chrome_trace_format()
with open('timeline_01.json', 'w') as f:
f.write(chrome_trace)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment