首页 文章

如何用tensorflow中的估算器绘制我的评估损失?

提问于
浏览
-1

嗨,我想绘制像这样的训练损失的评估损失: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)

当我把“损失”:指标丢失我得到一个错误,我该怎么办?

1 回答

  • 0

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

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

    例如: loss='mean_squared_error'

相关问题