Why does online prediction fail with “Unable to get element from the feed as bytes”?

半城伤御伤魂 提交于 2019-12-23 16:17:05

问题


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()

回答1:


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".



来源:https://stackoverflow.com/questions/40340102/why-does-online-prediction-fail-with-unable-to-get-element-from-the-feed-as-byt

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