Share via


How to operationalize Keras models in Microsoft Machine Learning Server

Microsoft Machine Learning Server’s operationalization feature enables data scientists to operationalize their R and Python analytics. In this blog, we will see how to operationalize Keras models as web services in R and Python.

Click here to know more about Microsoft Machine Learning Server Operationalization. You can configure Machine Learning Server to operationalize analytics on a single machine (One-box). 

Create a web service for Keras models in Python

Before you can use the web service management functions in the azureml-model-management-sdk Python package, you must:

  •  Have access to a Python-enabled instance of Machine Learning Server that was properly configured to host web services.
  • Authenticate with Machine Learning Server in Python as described in "Connecting to Machine Learning Server."
  • Have Keras, Tensorflow, and keras-pickle-wrapper installed.
  • Have a trained Keras model.

Here is a sample python code to create a simple WebService, publish it, and generate swagger. The below sample uses the Keras model  to recognize handwritten digits from the MNIST dataset.

For fast web service connections in Python, you can create sessions and load dependencies in advance by using dedicated session pool.

Create a web service for Keras models in R

  • Have access to a Machine Learning Server instance that was properly configured to host web services.
  • Authenticate with Machine Learning Server using the remoteLogin() or remoteLoginAAD() functions in the mrsdeploy package.
  • Install Keras and Tensorflow backend described here.
  • Have a trained Keras model.

Here is a sample R code to create a simple WebService, publish it, and generate swagger. The below sample uses the Keras model  to recognize handwritten digits from the MNIST dataset.

For fast web service connections in R, you can create sessions and load dependencies in advance by using dedicated session pool.

REFERENCES

https://keras.io/ https://keras.rstudio.com/ https://www.tensorflow.org/ https://yann.lecun.com/exdb/mnist/ https://pypi.org/project/keras-pickle-wrapper/ https://tensorflow.rstudio.com/keras/reference/install_keras.html /en-us/machine-learning-server/