Tensorflow Estimator:在单独的脚本中使用predict()函数 [英] Tensorflow Estimator: using predict() function in separate script

查看:891
本文介绍了Tensorflow Estimator:在单独的脚本中使用predict()函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经(希望)成功地使用tf.Estimator训练和评估了模型,我的火车/评估准确度达到了83-85%。所以现在,我想使用Estimator类中的predict()函数调用在单独的数据集上测试模型。最好是我想在单独的脚本中执行此操作。

I have successfully (I hope) trained and evaluated a model using the tf.Estimator where I reach a train/eval accuracy of around 83-85%. So now, I would like to test my model on a separate dataset using the predict() function call in the Estimator class. Preferably I would like to do this in a separate script.

我在,它说我需要导出为SavedModel,但这真的有必要吗?查看文档 Estimator类,似乎我可以通过 model_dir 参数将路径传递到检查点和图形文件。有没有人有任何经验?当我在用于验证的同一数据集上运行模型时,无法获得与验证阶段相同的性能...:-(

I've at this which says that I need to export as a SavedModel, but is this really necessary? Looking at the documentation for the Estimator class, it seems like I can just pass the path to my checkpoint and graph files via the model_dir parameter. Has anyone any experience with this? When I run my model on the same dataset I used for validation, I do not obtain the same performance as during the validation phase... :-(

推荐答案

我认为您只需要一个包含您的 model_fn 定义的文件,而不是使用相同的<$ c在另一个脚本中实例化相同的估计器类。 $ c> model_fn 定义和相同的 model_dir

I think you just need a separate file containing your model_fn definition. Than you instantiate the same estimator class in another script, using the same model_fn definition and the same model_dir.

这是有效的,因为估算器API会自行恢复 tf.Graph 定义和最新的 model.ckpt 文件,以便您可以继续进行培训,评价和预测。

That works because the Estimator API recovers the tf.Graph definitions and the latest model.ckpt files by itself so you are able to continue training, evaluation and prediction.

这篇关于Tensorflow Estimator:在单独的脚本中使用predict()函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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