Tensorflow Estimator: using predict() function in separate script

馋奶兔 提交于 2019-12-08 12:51:01

问题


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.

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... :-(


回答1:


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.

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.



来源:https://stackoverflow.com/questions/47783391/tensorflow-estimator-using-predict-function-in-separate-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!