Version inconsistency for training and prediction in Cloud ML

116 views Asked by At

it looks that Cloud ML has been migrated to TensorFlow 0.12.0. (I confirmed it from the exported model file. I need to use 0.12.0 to import the model generated on Cloud ML.)

But I suspect that Cloud ML's prediction feature is still running on prior version since it returns 503(Online prediction service is unavailable) when I use the exported model which I generated recently on Cloud ML.

Can someone from Google confirm this is the case?

2

There are 2 answers

0
Lak On

Online prediction is alpha at present, and so it needs some special sauce to get right. Here's an example of something that works. Note the use of 'instances', 'examples', and presence of a dummy value for the target column ('fare_amount' in my case).

from googleapiclient import discovery
from oauth2client.client import GoogleCredentials
import json

import google.cloud.ml.features as features
from google.cloud.ml import session_bundle

credentials = GoogleCredentials.get_application_default()
api = discovery.build('ml', 'v1beta1', credentials=credentials,
            discoveryServiceUrl='https://storage.googleapis.com/cloud-ml/discovery/ml_v1beta1_discovery.json')

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

parent = 'projects/%s/models/%s/versions/%s' % ('cloud-training-demos', 'taxifare', 'v1')
response = api.projects().predict(body=request_data, name=parent).execute()
print "response={0}".format(response)
0
Nikhil Kothari On

A quick note that Cloud ML Engine is now a v1 product with the online prediction part of it in Beta.

If you use the v1 endpoint (as opposed to v1beta1), the default behavior is to use TensorFlow 1.0 across both training and prediction. So things should be consistent and more reliable.