내가 실행 시간을 얻기 위해 타임 라인을 객체를 사용하는 방법에 대한보다 완전한 답변을주고 싶어 그래프의 각 노드에 대해 :
- 당신이
sess.run()
고전하지만 지정하는 인수를 사용 options
및 run_metadata
- 당신은 다음과 타임 라인 객체를 생성
run_metadata.step_stats
데이터
다음은 예제 코드입니다 :
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)
그런 다음 구글 크롬을 열 수, 페이지 chrome://tracing
로 이동하여 timeline.json
파일을로드합니다. 당신이해야 같은 : [여기]
유사 문제 (http://stackoverflow.com/questions/36439483/how-to-get-the-time-consumed-to-execute-each- 노드 - 인 - 텐서 흐름 그래프). 기본적으로'sess.run()'에 특정 옵션을 전달하고 TimeLine 객체를 사용합니다. –
Ahh TimeLine 객체 ... 대략 내가 무엇을하려고했는지 대략 – user3391229