【问题标题】:How can I plot my evaluation loss with estimators in tensorflow?如何在张量流中使用估计器绘制我的评估损失?
【发布时间】:2019-02-04 13:43:55
【问题描述】:

您好,我想像训练损失一样绘制评估损失,如下所示: image ,不只是像tensorflow教程那样的点,我是怎么做的,这是我的代码,用这个代码我只得到一个点来表示评估损失:

accuracy=tf.metrics.accuracy(labels=labels, predictions=predictions["classes"])
    metrics = {"accuracy": accuracy}
    tf.summary.scalar("accuracy", accuracy[1])

    #Configure of the training operation
    if mode==tf.estimator.ModeKeys.TRAIN:
        optimizer = tf.train.GradientDescentOptimizer(learning_rate=0.001)
        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)


    #Configure the evaluation operation
    if mode == tf.estimator.ModeKeys.EVAL:
        return tf.estimator.EstimatorSpec(mode=mode, loss=loss, eval_metric_ops=metrics)

当我在指标中输入 "loss":loss 时出现错误,我该怎么做?

【问题讨论】:

    标签: tensorflow deep-learning conv-neural-network tensorboard


    【解决方案1】:

    您必须指定要使用的损失类型:

    查看文档:https://keras.io/losses/

    例如:loss='mean_squared_error'

    【讨论】:

      猜你喜欢
      • 2019-08-02
      • 2018-11-07
      • 2019-04-11
      • 2018-08-30
      • 2020-04-09
      • 2018-10-06
      • 1970-01-01
      • 2019-04-28
      • 1970-01-01
      相关资源
      最近更新 更多