Skip to content

Instantly share code, notes, and snippets.

@monklof
Created August 29, 2019 09:37
Show Gist options
  • Save monklof/55a6e1f3d73201eb8ff14b929aa98540 to your computer and use it in GitHub Desktop.
Save monklof/55a6e1f3d73201eb8ff14b929aa98540 to your computer and use it in GitHub Desktop.
tf_timeline.py
import tensorflow as tf
from tensorflow.python.client import timeline
run_options = tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE)
run_metadata = tf.RunMetadata()
predictions = use_sess.run(use_out, {'DecodeJpeg/contents:0': image_file.file.getvalue()}, options=run_options, run_metadata=run_metadata)
# Create the Timeline object, and write it to a json
tl = timeline.Timeline(run_metadata.step_stats)
ctf = tl.generate_chrome_trace_format()
with open('timeline.json', 'w') as f:
f.write(ctf)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment