为什么在线预测会失败,并显示“无法从提要中获取元素作为字节"? [英] Why does online prediction fail with "Unable to get element from the feed as bytes"?

查看:43
本文介绍了为什么在线预测会失败,并显示“无法从提要中获取元素作为字节"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在线预测失败,提示无法从提要中获取元素作为字节".这是什么意思,我该如何解决?

Online prediction is failing with "Unable to get elements from the feed as bytes". What does this mean and how can I fix it?

我正在使用以下代码生成预测:

I'm generating predictions using the following code:

request_data = [{ 'examples' : 
    {'pickup_longitude': -73.885262,
     'pickup_latitude': 40.773008,
     'dropoff_longitude': -73.987232,
     'dropoff_latitude': 40.732403,  
     'fare_amount': 0,
     'passenger_count': 2}}]

parent = 'projects/%s/models/%s/versions/%s' % ('some project', 'taxifare', 'v1')
response = api.projects().predict(body={'instances': request_data}, name=parent).execute()

推荐答案

问题是我没有将元数据文件作为模型的一部分.元数据文件告诉Cloud ML服务如何将json记录转换为序列化的示例原型.没有元数据文件,转换将不会发生,结果tf.parse_example将失败,并显示错误无法从提要中获取元素作为字节".

The problem was that I didn't include a metadata file as part of the model. The metadata file tells the Cloud ML service how to convert json records to serialized example protos. Without the metadata file, conversion won't take place and as a result tf.parse_example will fail with the error "Unable to get element from the feed as bytes".

这篇关于为什么在线预测会失败,并显示“无法从提要中获取元素作为字节"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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