1

tf.estimator.train_and_evaluate(...)tf.estimator.Estimator配置为 的 一起使用时tf.contrib.learn.RunConfig(save_checkpoints_steps=10, ...)CheckpointSaverHook将自动创建一个。这CheckpointSaverHook将在每次触发时将图形和 graph_def 保存到摘要编写器(请参阅CheckpointSaverHook.before_run)。

基本代码示例:

estimator = tf.estimator.Estimator(
    model_fn, model_dir, params,
    config=tf.estimator.RunConfig(
        save_checkpoints_steps=100, 
        save_summary_steps=100
    )
)
train_spec = tf.estimator.TrainSpec(train_fn)
eval_spec = tf.estimator.TrainSpec(eval_fn)
tf.estimator.train_and_evaluate(estimator, train_spec, eval_spec)

在书面摘要上启动 Tensorboard 时,由于摘要中有多个图形定义,它会输出数百个警告,我猜这会在启动时减慢它的速度:

W0117 18:47:30.278879 Reloader tf_logging.py:86] Found more than one graph event per run, or there was a metagraph containing a graph_def, as well as one or more graph events.  Overwriting the graph with the newest event.
W0117 18:47:30.279753 Reloader tf_logging.py:86] Found more than one metagraph event per run. Overwriting the metagraph with the newest event.

我发现使用多个图表时可能会出现问题,但是对于单个图表,这似乎不切实际。我们是否在这里正确使用了估计器,并且这种行为是有意的吗?我们是否需要编写一个自定义钩子来防止这种情况发生?

谢谢你的建议!

编辑:由于评论的建议,现在有一个问题: https ://github.com/tensorflow/tensorflow/issues/17272

4

0 回答 0