Tensorflow Estimator 框架中没有 Tensorboard 日志记录

No Tensorboard logging in Tensorflow Estimator framework

我正在使用 Estimator 训练我的网络。我想用 Tensorboard 进行监控。 Estimator 的博客声明如下:

"The training will output information like the global step, loss, 
and accuracy over time on the terminal output. Besides this, the
Experiment and Estimator framework will log certain statistics to 
be visualized by TensorBoard."

https://medium.com/onfido-tech/higher-level-apis-in-tensorflow-67bfb602e6c0

我的进程确实创建了事件文件,但里面什么也没有。

These tags are in checkpoints/1504359209.469093:
audio -
histograms -
images -
scalars -
tensor -

什么控制 Estimator 写入哪些标量,以及写入它们的频率?

首先,文档在这一点上不是很清楚。 为避免编写教程,这里有几点可能对您有所帮助,尽管我应该说我不太清楚您的代码当前是如何设置的。

  • 您不希望创建 FileWriter。相反,您只是要向 model_fn 添加 tf.summary.scalar 和 tf.name_scope 注释。
  • 您不想从 sess.run 传回任何东西。这是我的第一个猜测,我可以确认您可以保留 Estimator 并且不需要重组。
  • 您应该查看创建估算器的行 (estimator.Estimator(model_fn=...))。在此行中,您指定 model_dir,这是您将指向 tensorboard 的 logdir 参数的位置。估算器自动记录到 model_dir,它们不需要 FileWriter。你可能已经知道这一点,因为你可以看到事件输出,但我提到它是为了防止它发现我们正在做的事情之间存在一些不一致。
  • 您还应该查看传递给估算器的 RunConfig。我的包含密钥 save_summary_steps,我认为它控制写入发生的频率。

谢谢。这很有帮助。

我已经使用默认标量使其正常工作,但您的建议将使我能够添加新标量。

就我而言,问题出在数据输入上。我复制了使用数据集的现有代码。这是我的代码

        # Build dataset iterator
        dataset = tf.contrib.data.Dataset.from_tensor_slices(
        # dataset = tf.contrib.data.Dataset.from_tensors(
            (fingerprints_placeholder, labels_placeholder))
        #dataset = dataset.repeat(None)  # Infinite iterations
        #dataset = dataset.shuffle(buffer_size=10000)
        dataset = dataset.batch(batch_size)
        iterator = dataset.make_initializable_iterator()

注意注释掉的行。由于某种原因,它们导致代码永远 运行 而没有输出。删除它们后,一切都会像宣传的那样工作。