Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. import tensorflow as tf
  2. from tensorflow.python.client import timeline
  3. from keras import backend as K
  4.  
  5. run_options = tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE)
  6. run_metadata = tf.RunMetadata()
  7.  
  8. model = ... # A Keras model
  9.  
  10. fn = K.function(model.inputs, model.outputs, options=run_options, run_metadata=run_metadata)
  11.  
  12. for i in range(4):
  13. x = K.variable(...)
  14. fn([x])
  15. tl = timeline.Timeline(run_metadata.step_stats)
  16. ctf = tl.generate_chrome_trace_format()
  17. with open('timeline_%d.json' % (i), 'w') as f:
  18. f.write(ctf)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement