The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Deploying Models

You can host your trained machine learning models in the cloud and use the Cloud ML prediction service to infer target values for new data. This page discusses model hosting and prediction and introduces considerations you should keep in mind for your projects.

Model Deployment

Cloud ML Engine can host your models so that you can get predictions from them in the cloud. The process of hosting a saved model is called deployment. The prediction service manages the infrastructure needed to run your model at scale, and makes it available for online and batch prediction requests. This section describes model deployment.

Exporting a SavedModel

The Cloud ML prediction service makes use of models exported through the export_savedmodel() function which is available for models created using the tensorflow, keras and tfestimators packages or any other tool that support the tf.train.Saver interface.

For instance, we can use examples/keras/train.R included in this package to define and train an MNIST keras model by running:

Deploying the Model

Deployment is performed through cloudml_deploy() which uses the same gcloud and cloudml configuration concepts used while training. We can train any exported model by running:

Copying file://savedmodel/variables/variables.data-00000-of-00001 [Content-Type=application/octet-stream]...
Copying file://savedmodel/saved_model.pb [Content-Type=application/octet-stream]...
Copying file://savedmodel/variables/variables.index [Content-Type=application/octet-stream]...
/ [3/3 files][  1.9 MiB/  1.9 MiB] 100% Done                                    
Operation completed over 3 objects/1.9 MiB.

Model created and available in https://console.cloud.google.com/mlengine/models/keras_mnist

Notice that models make use of unique names and versions which can be specified using the name and version parameters in cloudml_deploy().

Prediction

Once a model is deployed, predictions can be performed by providing a list of inputs into cloudml_predict():

mnist_image <- keras::dataset_mnist()$train$x[1,,]
grid::grid.raster(mnist_image / 255)


cloudml_predict(
  list(
    as.vector(t(mnist_image))
  ),
  name = "keras_mnist",
)
$predictions
                       dense_3
1 0, 0, 0, 0, 0, 1, 0, 0, 0, 0

For additional information visit Google Cloud Platform - Prediction Basics

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.