无法在Google Cloud ml上进行预测,而本地计算机上正在使用相同的模型 [英] Unable to make predictions on google cloud ml, whereas same model is working on the local machine

查看:56
本文介绍了无法在Google Cloud ml上进行预测,而本地计算机上正在使用相同的模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Google云中训练一个机器学习模型usinf tensorflow库.创建存储桶后,我可以在云中训练模型.当我尝试使用现有模型进行预测时,我面临着这个问题.代码和数据位于以下Github目录中. https://github.com/terminator172/game-price-predictions

云上的tensorflow版本是1.8,而我系统上的tensorflow版本也是1.8

我尝试通过提供以下输入进行预测"gcloud ml-engine预测--model = earnings --version = v8 --json-instances = sample_input_prescaled.json"

它因以下错误而出错"{错误":预测失败:模型执行期间出错:AbortionError(code = StatusCode.FAILED_PRECONDITION,details = \"尝试使用未初始化的值output/biases4 \ n \ t [[节点:output/biases4/read = IdentityT = DT_FLOAT,_output_shapes = [[1]],_device = \"/job:localhost/副本:0/task:0/device:CPU:0 \"]] \)"}"

解决方案

您在gcloud中的模型目录(使用-model 标志提供的模型目录)应包含2个内容:

  1. saved_model.pb 文件,包含实际的TensorFlow程序或模型,以及一组命名签名,每个签名均标识一个接受张量输入并产生张量输出的函数.

  2. p>
  3. 变量目录,其中包含标准的训练检查点.

如果缺少 variables 目录,并且只有 saved_model.pb 文件,则可以获取此尝试使用未初始化的值错误.为了对其进行修复,您只需将 variables 目录添加到gcloud中的模型目录中.

参考: Tensorflow SavedModel格式

I am trying to train a machine learning model usinf tensorflow library in the google cloud. I am able to train the model in the cloud after creating a bucket. I am facing the issue when I am tring to make predictions using the existing model. The code and the data is available in the following Github directory. https://github.com/terminator172/game-price-predictions

The tensorflow version on the cloud is 1.8 and the tensorflow version on my system is also 1.8

I tried to make predictions by giving the following input "gcloud ml-engine predict --model=earnings --version=v8 --json-instances=sample_input_prescaled.json"

It errored out with the following error "{ "error": "Prediction failed: Error during model execution: AbortionError(code=StatusCode.FAILED_PRECONDITION, details=\"Attempting to use uninitialized value output/biases4\n\t [[Node: output/biases4/read = IdentityT=DT_FLOAT, _output_shapes=[[1]], _device=\"/job:localhost/replica:0/task:0/device:CPU:0\"]]\")" }"

解决方案

Your model directory in gcloud (the one that you provide with the --model flag) should contain 2 things:

  1. The saved_model.pb file, containing the actual TensorFlow program, or model, and a set of named signatures, each identifying a function that accepts tensor inputs and produces tensor outputs.

  2. The variables directory, containing a standard training checkpoint.

In case your variables directory is missing and you have only the saved_model.pb file, you can get this Attempting to use uninitialized value error. In order to fix it you just need to add the variables directory to your model directory in gcloud.

Reference: Tensorflow SavedModel format

这篇关于无法在Google Cloud ml上进行预测,而本地计算机上正在使用相同的模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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