Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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()
like image 775
Jeremy Lewi Avatar asked Dec 07 '25 16:12

Jeremy Lewi


1 Answers

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

like image 90
Jeremy Lewi Avatar answered Dec 10 '25 13:12

Jeremy Lewi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!