[英]TensorFlow Estimator tracking timeline?
A normal practice of timeline to track TensorFlow session is below: 跟踪TensorFlow会话的时间轴的常规做法如下:
import tensorflow as tf
from tensorflow.python.client import timeline
x = tf.random_normal([1000, 1000])
y = tf.random_normal([1000, 1000])
res = tf.matmul(x, y)
# Run the graph with full trace option
with tf.Session() as sess:
run_options = tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE)
run_metadata = tf.RunMetadata()
sess.run(res, 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)
But now I am using tf.estimator
, without defining a session explicitly. 但是现在我正在使用
tf.estimator
,而没有显式定义会话。 So how and when should I define and use tensorflow.python.client.timeline
? 那么我应该如何以及何时定义和使用
tensorflow.python.client.timeline
?
try this: 尝试这个:
hook = tf.train.ProfilerHook(save_steps=100, output_dir='/tmp/')
classifier.train(
input_fn=lambda: ltr_dataset.csv_input_fn(train_file_list, args.batch_size)
,hooks=[hook]
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.