TensorFlow - 如何从 tf.Estimaor 中获取损失值

TensorFlow - How to Get My Loss Value from tf.Estimaor

我正在尝试在 TensorFlow 中使用 tf.estimator 训练 alexnet 模型。训练过程很顺利,我可以看到日志显示得很好。

INFO:tensorflow:loss = 2.61362, step = 294
INFO:tensorflow:Saving checkpoints for 325 into /home/olu/Dev/data_base
sign_base/output/Checkpoints_N_Model/trained_alexnet_model/model.ckpt.
INFO:tensorflow:Loss for final step: 2.94104.

下面是训练函数的调用方式:

traffic_sign_classifier.train(input_fn=train_input_fn,hooks=[logging_hook])

拜托,我怎样才能从 tf 估计器对象

中获得作为正常 python 浮点数的损失值

您可以在完成训练后从 tensorboard 下载损失值。

估算器上的 .evaluate() 方法 returns 您可以在模型函数中指定的指标字典,在估算器规范中,https://www.tensorflow.org/api_docs/python/tf/estimator/EstimatorSpec eval_metric_ops. I found the answer on this thread on GitHub Link