glcoud local预测可行,但在线预测失败,并且NodeDef提到attr" output_type'不在Op"

时间:2018-01-23 15:14:05

标签: tensorflow google-cloud-ml

我使用TensorFlow在本地培训了一个模型,并将其上传到Google Cloud ML Engine。尽管使用gcloud ml-engine local predict的本地测试工作正常,但使用gcloud ml-engine predict的在线预测会因此错误而失败:

  

{     "错误":"预测失败:模型执行期间出错:AbortionError(代码= StatusCode.INVALID_ARGUMENT,details = \" NodeDef提及attr' output_type'不在Op中output:int64; attr = T:type,allowed = [DT_FLOAT,DT_DOUBLE,DT_INT64,DT_INT32,DT_UINT8,DT_UINT16,DT_INT16,DT_INT8,DT_COMPLEX64,DT_COMPLEX128,DT_QINT8,DT_QUINT8,DT_QINT32,DT_HALF]; attr = Tidx:type,default = DT_INT32,allowed = [DT_INT32,DT_INT64]&gt ;; NodeDef:dnn / head / predictions / class_ids = ArgMax [T = DT_FLOAT,Tidx = DT_INT32,_ output_shapes = [[ - 1]],output_type = DT_INT64,_device = \&# 34; / job:localhost / replica:0 / task:0 / cpu:0 \"](dnn / head / logits,dnn / head / predictions / class_ids / dimension)\ n \ t [[Node:dnn / head / predictions / class_ids = ArgMax [T = DT_FLOAT,Tidx = DT_INT32,_output_shapes = [[ - 1]],output_type = DT_INT64,_device = \" / job:localhost / replica:0 / task:0 / cpu:0 \"](dnn / head / logits,dnn / head / predictions / class_ids / dimension)]] \")"   }

1 个答案:

答案 0 :(得分:1)

问题是TensorFlow的不同版本:我本地计算机上的1.4.1,我用于培训,1.2用于Google Cloud。您可以在使用CLI工具时指定版本,但不能使用Google Cloud Web控制台,因此解决方案是使用gcloud ml-engine versions create--runtime-version=1.4参数。

这个答案有所帮助(尽管还有另一条错误消息):https://stackoverflow.com/a/48080666/903919