Tensorflow估算器-评估数据集的定期评估 [英] Tensorflow Estimator - Periodic Evaluation on Eval Dataset

查看:114
本文介绍了Tensorflow估算器-评估数据集的定期评估的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

tensorflow文档未提供有关如何对评估集执行模型的定期评估的任何示例。

The tensorflow documentation does not provide any example of how to perform a periodic evaluation of the model on an evaluation set.

有人建议听起来不错,但不幸的是,无法使用实验(折旧并触发错误)。

Some people suggested the use of an Experiment, which sounds great but unfortunately does not work (depreciation and triggers an error).

其他建议使用SummarySaverHook,但我看不出如何将其与评估集结合使用(相对

Others suggested the use of SummarySaverHook, but I don't see how you can use that with an evaluation set (as opposed to the training set).

一种解决方案是执行以下

A solution would be to do the following

for i in range(number_of_epoch):
    estimator.train(...) // on training set
    estimator.evaluate(...) // on evaluation set

此架构在本文(右上角第4页)。

This architecture is explicitly discouraged in this paper (page 4 top right).

还有其他想法/实现吗?

Any other idea/implementation?

编辑:

运行时的错误消息实验如下:

The error message when running the experiment is the following:

File ".../anaconda2/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/experiment.py", line 253, in train if (config.environment != run_config.Environment.LOCAL and
AttributeError: 'RunConfig' object has no attribute 'environment'

Tensorflow版本1.3

Tensorflow version 1.3

推荐答案

仅弃用了 Experiment 的一些参数/选项(您看到什么具体错误?)。如果您创建一个 Estimator 来执行定期检查点(使用 RunConfig )和使用它的 Experiment ,您将获得对每个检查点的评估使用 train_and_evaluate 方法。

Only a few parameters/options of Experiment are deprecated (what specific errors are you seeing?). If you create an Estimator that will do periodic checkpoints (using options in RunConfig) and an Experiment using it, you will get evaluation for each checkpoint by default when using train_and_evaluate method.

编辑:正如Maxime在评论中指出的那样。他需要添加以下行来消除他的错误:

As Maxime pointed out in the comments. He needed to add the following lines to get rid of his error:

os.environ['TF_CONFIG'] = json.dumps({'environment': 'local'})
config = tf.contrib.learn.RunConfig()

这篇关于Tensorflow估算器-评估数据集的定期评估的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆