liveBook · Manning

TensorFlow Serving

As explained in Deep Learning with R, Third Edition

TensorFlow Serving is a system for serving trained machine-learning models through production prediction APIs.

TensorFlow Serving exposes trained models through prediction APIs by separating model weights and computation graphs from the R or Python application. section 6.3.2

library(keras3)
model |>
  export_savedmodel("path/to/location", format = "tf_saved_model")  #1

reloaded_artifact <- tensorflow::tf$saved_model$load("path/to/location")  #2
predictions <- reloaded_artifact$serve(input_data)

Export a Keras model as a TensorFlow SavedModel, reload the serving artifact, and call its serve function with input data. section 6.3.2

Use this deployment pattern when:

  • A separate application environment, such as C++ or JavaScript, needs to consume predictions through a REST API. section 6.3.2
  • The application has reliable internet access, tolerates roughly 500 ms round trips, and can send non-sensitive input data to a server. section 6.3.2

How Deep Learning with R, Third Edition covers it

How deep it goes
Explains export, reload, and serving, but stops short of server configuration and API implementation details.
Examples
Uses a Keras SavedModel export, TensorFlow reload, and serve call as the concrete deployment example.
What it assumes
Assumes a trained Keras model and introduces deployment after training rather than model construction or optimization procedures.
What you can do after
Apply it via Keras and TensorFlow APIs to export a model artifact and obtain predictions from the reloaded artifact.
How it connects
Connects TensorFlow Serving with Keras, tf_function, REST APIs, inference, and ONNX.

Also explained in

Compare how 2 books explain TensorFlow Serving →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Deep Learning with R, Third Edition. The section links point to the parts of the book it draws on.