如何为tf.data.Dataset创建性能时间表?

Pio*_*pla 5 tensorflow tensorflow-datasets

我想看看我的Tensorflow数据集pipline只要需要,不幸的是,当我运行分析我的数据集的整体执行一个操作所覆盖:“IteratorGetNext”。有没有一种方法可以窥视“数据集”图的内部以分别查看每个地图?

这里是一个可以进行运行加入num_parallel_calls更快不幸的是我们不能告诉大家,从时间线作为整个操作出现(见截图)简约的例子

import tensorflow as tf
from tensorflow.python.ops import io_ops
from tensorflow.contrib.framework.python.ops import audio_ops

g = tf.Graph()
with g.as_default():
  ds = tf.data.Dataset.list_files("work/input/train/audio/**/*.wav")
  ds = (ds
        .map(lambda x: io_ops.read_file(x))
        .map(lambda x: audio_ops.decode_wav(x,
                                 desired_channels=1,
                                 desired_samples=16000))
        .batch(30*1000)
        .prefetch(2)
  )

  iterator = ds.make_one_shot_iterator()
  get_next = iterator.get_next()


run_metadata = tf.RunMetadata()
run_config = tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE)


with tf.Session(graph=g) as sess:
  sess.run(get_next,
           options=tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE),
           run_metadata=run_metadata)

from tensorflow.python.client import timeline
trace = timeline.Timeline(step_stats=run_metadata.step_stats)

trace_file = open('timelines/example.json', 'w')
trace_file.write(trace.generate_chrome_trace_format())
trace_file.close()
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明