【问题标题】:How to add more details on tensorboard using estimator API如何使用 estimator API 在 tensorboard 上添加更多细节
【发布时间】:2019-01-10 14:30:07
【问题描述】:

我让我的模型跟随https://www.tensorflow.org/tutorials/estimators/cnn

我将 SummarySaverHook 添加到我的模型中

    summary_hook = tf.train.SummarySaverHook(
    100,
    output_dir='C:/Users/dir',
    summary_op=tf.summary.merge_all())

# Configure the Training Op (for TRAIN mode)
if mode == tf.estimator.ModeKeys.TRAIN:
    optimizer = tf.train.GradientDescentOptimizer(learning_rate=0.01)
    train_op = optimizer.minimize(
        loss=loss,
        global_step=tf.train.get_global_step())
    return tf.estimator.EstimatorSpec(mode=mode, loss=loss, train_op=train_op, training_hooks=[summary_hook])

但是当我运行一个 get only enqueue_input 图表(我不知道它是什么)和模型图时。我想要获得准确性和损失图表。

所以我想在我的张量板上提供一些细节。

  1. 损失和准确度字符
  2. 可以及时得到准确度图表,因为在估算器中我只有在最后一步之后才能得到准确度。
  3. 我可以在 tensorboard 中获得更多细节,比如错误的预测图像吗?但是没有 Session 和 Graph 创建,只能通过 estimator api?

【问题讨论】:

    标签: tensorflow tensorboard tensorflow-estimator


    【解决方案1】:

    首先,你不需要使用summary_hook。您只需在指定 logits 后立即使用 tf.metrics 指定所需的指标。

     logits = tf.layers.dense(inputs=dropout, units=10)
    
     predictions = {
              "classes": tf.argmax(input=logits, axis=1),
              "probabilities": tf.nn.softmax(logits, name="softmax_tensor")
     }
    
     accuracy = tf.metrics.accuracy(labels=labels, predictions=predictions['classes']
     tf.summary.scalar('acc', accuracy[1])
    

    然后把这个 tf.logging.set_verbosity(tf.logging.INFO) 在您输入之后,如果您还没有这样做。

    您可以通过将eval_metric_ops = {'accuracy': accuracy} dict 插入tf.estimator.EstimatorSpec 来绘制评估指标

    您可以使用tf.summary 来可视化图像、权重和偏差等。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-24
      • 2019-02-26
      • 2016-11-22
      • 1970-01-01
      相关资源
      最近更新 更多