Skip to content

Instantly share code, notes, and snippets.

@sborquez
Last active November 3, 2019 15:19
Show Gist options
  • Save sborquez/e2d4802e2ec490997da857bd784869c9 to your computer and use it in GitHub Desktop.
Save sborquez/e2d4802e2ec490997da857bd784869c9 to your computer and use it in GitHub Desktop.
Find the bottleneck of your model.
import tensorflow as tf
from tensorflow.python.client import timeline
import keras
tl = timeline.Timeline(run_metadata.step_stats)
ctf = tl.generate_chrome_trace_format()
run_options = tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE)
run_metadata= tf.RunMetadata()
model = ...
model.compile(..., options=run_options, run_metadata=run_metadata)
model.fit(...)
with open("output.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