Google Cloud ML FAILED_PRECONDITION [英] Google Cloud ML FAILED_PRECONDITION

查看:73
本文介绍了Google Cloud ML FAILED_PRECONDITION的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Google Cloud ML托管Tensorflow模型并获得预测.我有一个预先训练的模型,已经上传到云中,并且已经在Cloud ML控制台中创建了模型和版本.

I am trying to use Google Cloud ML to host a Tensorflow model and get predictions. I have a pretrained model that I have uploaded to the cloud and I have created a model and version in my Cloud ML console.

我按照说明从此处执行准备我的数据以请求在线预测.对于Python方法和glcoud方法,我都会遇到相同的错误.为简单起见,我将发布gcloud方法:

I followed the instructions from here to prepare my data for requesting online predictions. For both the Python method and the glcoud method I get the same error. For simplicity, I'll post the gcloud method:

我运行gcloud ml-engine predict --model spell_correction --json-instances test.json,其中test.json是我的输入数据文件(名为instances的JSON数组).我得到以下结果:

I run gcloud ml-engine predict --model spell_correction --json-instances test.json where test.json is my input data file (a JSON array named instances). I get the following result:

ERROR: (gcloud.ml-engine.predict) HTTP request failed. Response: {
  "error": {
  "code": 400,
  "message": "Precondition check failed.",
  "status": "FAILED_PRECONDITION"
  }
}

如何获得有关此的更多详细信息?当我尝试通过Python进行调试时,同样的确切错误也会发生,并且我有一个包含错误的googleapiclient.http.HttpRequest对象.我只想知道为什么除了此一般错误之外,还会发生此错误.有谁知道如何通过Python方法或gcloud方法获取更多详细信息?我假设由于这是相同的错误,因此是相同的根本原因.

How can I get more details about this? The same exact error happens when I try via Python and there I have a googleapiclient.http.HttpRequest object containing the error. I just want to know why this error is happening other than this generic error. Does anyone know how to get more details via either the Python method or the gcloud method? I am assuming that since it is the same error, it is the same root cause.

gcloud ml-engine models list的输出:

NAME              DEFAULT_VERSION_NAME
spell_correction  testing

gcloud ml-engine versions list --model spell_correction

NAME     DEPLOYMENT_URI
testing  gs://<my-bucket>/output/1/

test.json:{"instances": [{"tokens": [[9], [4], [11], [9]], "mask": [[18], [7], [12], [30]], "keep_prob": 1.0, "beam": 64}]}

我对模型的输入

tokens:tf.placeholder(tf.int32, shape=[None, None])

mask:tf.placeholder(tf.int32, shape=[None, None])

keep_prob:tf.placeholder(tf.float32)

beam:tf.placeholder(tf.int32)

通过python调用时,request_body只是test.json作为字符串.

When calling via python, the request_body is just test.json as a string.

推荐答案

在与Google Cloud ML支持进行交谈之后,我开始了这项工作.

After talking to Google Cloud ML support, I got this working.

我注意到的主要问题是test.json中的所有数据在发送到模型时都被包装在一个列表中.我通过从上面的文件中的tokensmask中删除外部列表来解决此问题.我也将keep_probbeam更改为常量,因为我不希望它们对我所做的每个预测都能够更改.

The main issue I noticed was that all of the data in test.json gets wrapped in a list when it is sent to your model. I solved this by removing the outer list from tokens and mask in my file above. I also changed keep_prob and beam to constants as I do not want them to be able to change for every prediction I make.

作为一般性建议,通过Python调用提供的错误消息比gcloud ml-engine predict中的错误消息对我有用得多.另外,请确保您的gcloud安装保持最新,它们几乎一直在进行修复.

As a general piece of advice, the error messages provided through the Python call were much more useful to me than the error messages from gcloud ml-engine predict. Also ensure to keep your gcloud install up-to-date, they are working on fixes almost constantly.

这篇关于Google Cloud ML FAILED_PRECONDITION的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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