swigganicks
swigganicks

Reputation: 1231

How to modify TensorFlow code to accept samples for prediction on Google Cloud ML?

I tried to create a model on Google Cloud ML after exporting my trained model from Cloud Storage but the error I got was:

Create Version failed. Model validation failed: SavedModel must contain exactly one metagraph with tag: serve For more information on how to export Tensorflow SavedModel, seehttps://www.tensorflow.org/api_docs/python/tf/saved_model.

So I only have one TensorFlow .add_meta_graph_and_variables() in my training. Am I supposed to make another one to handle new inputs? I don't fully understand the process for creating a serving meta graph and how I can set up my code to evaluate a single instance.

Upvotes: 0

Views: 197

Answers (1)

Lak
Lak

Reputation: 4166

Yes, if you are using core TensorFlow, you should export a separate prediction graph. See:

https://github.com/GoogleCloudPlatform/cloudml-samples/blob/master/census/tensorflowcore/trainer/model.py

If you are using the Estimator API, simply use Experiment and pass in an export function. I strongly suggest using Estimator/Experiment rather than core TensorFlow

https://github.com/GoogleCloudPlatform/cloudml-samples/blob/master/census/estimator/trainer/task.py#L43

Upvotes: 1

Related Questions