liveBook · Manning

REST

As explained in Deep Learning with R, Third Edition

A REST API is a web interface that exposes resources or operations through HTTP requests following REST architectural conventions.

A REST API turns a trained inference model into an online product. It separates model weights and the computation graph from the R or Python application, allowing predictions to be served from another environment. section 6.3.2

Exporting a Keras model for serving

Export a Keras model as a TensorFlow SavedModel, reload the artifact, and call its serving function with input data. An equivalent workflow uses ONNX and ONNX Runtime. 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)

Runnable R code exports a Keras model, reloads the TensorFlow artifact, and obtains predictions through its serving interface. section 6.3.2

Typical deployment choices include:

  • TensorFlow Serving serves a computation graph with saved weights. section 6.3.2
  • ONNX exports the model for execution through ONNX Runtime. section 6.3.2
  • Posit Connect can directly serve an exported Keras model. section 6.3.2

How Deep Learning with R, Third Edition covers it

How deep it goes
Explains exporting weights and computation graphs, then serving them through TensorFlow Serving or ONNX; it does not detail request schemas.
Examples
Demonstrates Keras SavedModel export, TensorFlow artifact loading, ONNX Runtime execution, and Posit Connect deployment.
What it assumes
Assumes a trained Keras model and inference inputs, while teaching how to export the model outside R or Python.
What you can do after
Apply it via TensorFlow Serving, ONNX Runtime, or Posit Connect to expose a trained model for prediction.
How it connects
Connects REST APIs with inference, model deployment, TensorFlow Serving, ONNX, ONNX Runtime, and computation graphs.

Also explained in

Compare how 22 books explain REST →

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.