-
Notifications
You must be signed in to change notification settings - Fork 19.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chrome timeline support on tensorflow #6606
Comments
I have never used it. But you could try something like this: from keras import backend as K
# Run the graph with full trace option
with K.get_session() as sess:
run_options = tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE)
run_metadata = tf.RunMetadata()
model.fit_generator(...)
# 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) |
Thankd for the quick response! I tried that out but my timeline.json is not recording anything, this is all there is in the file:
So my time line trace on chrome is actually empty. |
The issue is that |
Is this feature in the latest release? I'm getting the same results as stalagmite7. timeline.json is not recording anything. Can anyone provide an example program? Thanks. |
I'm also stuck on this, can you please provide an example to clarify? Thanks |
Sorry for the delay, something like the below should work: import keras
from keras.layers.core import Dense
from keras.models import Sequential
import tensorflow as tf
from tensorflow.python.client import timeline
x = np.random.randn(10000, 2)
y = (x[:, 0] * x[:, 1]) > 0 # xor
run_options = tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE)
run_metadata = tf.RunMetadata()
model = Sequential()
model.add(Dense(units=64, activation='relu', input_dim=2))
model.add(Dense(units=2, activation='softmax'))
model.compile(loss='categorical_crossentropy',
optimizer='sgd',
options=run_options,
run_metadata=run_metadata)
model.fit(x, keras.utils.to_categorical(y), epochs=1)
trace = timeline.Timeline(step_stats=run_metadata.step_stats)
with open('/tmp/timeline.ctf.json', 'w') as f:
f.write(trace.generate_chrome_trace_format()) Then go to As far as I'm aware, the canonical documentation for how to use this is in this comment. |
model.fit_generator didn't save anything for trace. Is this keras timeline only working on model.fit? |
@shensheng27 thank you for this suggestion! fit_generator indeed doesnt seem to save anything, but fit() does. Nice catch |
I've been looking at some profiling tools available, the chrome timeline from tensorflow looks super useful this stackoverflow post, but its not documented and the only examples I can find to piece together how to run it are tensorflow models.
I am running keras with a tf backend, and my sequential models are all built in keras. For instance, this is how my model is being built:
I am at a loss for how I would try to generate a timeline trace for this model, and wanted to know if Keras supports this? And how would I generate a trace for this?
Check that you are up-to-date with the master branch of Keras. You can update with:
pip install git+git://github.com/fchollet/keras.git --upgrade --no-deps
If running on TensorFlow, check that you are up-to-date with the latest version. The installation instructions can be found here.
If running on Theano, check that you are up-to-date with the master branch of Theano. You can update with:
pip install git+git://github.com/Theano/Theano.git --upgrade --no-deps
Provide a link to a GitHub Gist of a Python script that can reproduce your issue (or just copy the script here if it is short).
The text was updated successfully, but these errors were encountered: