TensorFlow-如何仅一次评估每个示例的所有测试集 [英] TensorFlow - how to evaluate all test set with every example once and only once

查看:121
本文介绍了TensorFlow-如何仅一次评估每个示例的所有测试集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行TensorFlow中的 cifar10 示例.但是评估存在问题.

I am running cifar10 example from TensorFlow. But there is a problem for evaluation.

我有一个测试集,我想一次评估一次所有示例.但是代码(第121行)现在仅从队列中获取(第126 行)不能保证这一点.我还对输入是".tfrecords"文件进行了修改.有什么建议吗?

I have a test set and I want to evaluate every example from it once and only once. But the code (line 121) now only takes from an queue (line 126) which can not guarantee that. I have also made a modification that input is a '.tfrecords' file. Is there any suggestion?

谢谢.

推荐答案

我想出了一个解决方案,但还不完善.提示是将其排除在要加载的变量之外,然后自己初始化limit_epochs.以下是详细步骤:

I have figured a solution but rather imperfect. The clue is exclude it from variables to load and then initialize the limit_epochs by one's own. Following is the detailed step:

添加代码 variables_to_restore = variable_averages.variables_to_restore()之后的del variables_to_restore['input_producer/limit_epochs/epochs'].并且它将停止将input_producer/limit_epochs加载到模型中.

Add the code del variables_to_restore['input_producer/limit_epochs/epochs'] after variables_to_restore = variable_averages.variables_to_restore(). And it will stop loading input_producer/limit_epochs to the model.

接下来,在会话中添加代码sess.run(tf.initialize_variables([v for v in tf.all_variables() if v.name.startswith("input_producer")]))以激活变量.

Next, add the code sess.run(tf.initialize_variables([v for v in tf.all_variables() if v.name.startswith("input_producer")])) in a session to activate the variable.

最后,执行操作filename_queue = tf.train.string_input_producer(filenames, num_epochs=1).

并在关闭线程之前尝试保存文件.

And try to save the files before shutting down the threads.

缺点是,如果您希望每个线程都适合任意测试示例,则必须使每个线程仅读取一个示例.

The imperfection is you have to make every thread read only one example if you want it fits arbitrary test examples.

这篇关于TensorFlow-如何仅一次评估每个示例的所有测试集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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