【问题标题】:Early stopping in Tensorflow using SessionRunHook() or validation monitor使用 SessionRunHook() 或验证监视器在 Tensorflow 中提前停止
【发布时间】:2017-05-08 20:09:54
【问题描述】:

我有一个运行良好的深度神经网络。但是,添加以下代码来实现提前停止会导致错误:

validation_metrics = {
"accuracy":
    tf.contrib.learn.MetricSpec(
        metric_fn=tf.contrib.metrics.streaming_accuracy,
        prediction_key=tf.contrib.learn.prediction_key.PredictionKey.
        CLASSES)}


validation_monitor = tf.contrib.learn.monitors.ValidationMonitor(
x=X_test, y=y_test, early_stopping_rounds=50, metrics=validation_metrics)

输出:

prediction_key=tf.contrib.learn.prediction_key.PredictionKey.CLASSES)}
AttributeError: module 'tensorflow.contrib.learn' has no attribute 'prediction_key'

【问题讨论】:

  • 您能否添加更多有关问题所在的详细信息,看看您是否可以减少重现错误所需的代码示例的大小?这将有助于我们更好地回答这个问题。
  • 谢谢 - 减少原始问题中的代码。完整代码要点here
  • 你用的是什么版本的tensorflow和python?
  • Python 3.6,为 GPU 启用了 TF '1.1.0-rc2'。

标签: tensorflow


【解决方案1】:

您可以尝试以下方法:

prediction_key=tf.contrib.learn.PredictionKey.CLASSES

【讨论】:

    【解决方案2】:

    所有显示器都是deprecated。

    最好的办法是查看training hooks。在撰写本文时,只有香草钩子可用。所以你需要实现你的own。

    【讨论】:

      猜你喜欢
      • 2020-11-16
      • 2018-05-17
      • 1970-01-01
      • 1970-01-01
      • 2019-03-18
      • 2021-05-08
      • 2019-03-09
      • 1970-01-01
      相关资源
      最近更新 更多