liveBook · Manning

REST

As explained in Deep Learning with Python, Third Edition

REST is an architectural style for distributed hypermedia systems that organizes interactions around resources and representations through constraints including a uniform interface, stateless communication, cacheability, and layered components.

A REST API can make a trained model available online for inference. Exporting its weights and computation graph lets it be served outside Python, including from environments such as C++. section 6.3.2

This option suits applications with reliable internet access and no strict latency requirements; a request, inference, and response round trip typically takes around 500 ms. Mobile apps may be unavailable in airplane mode or low-connectivity settings. section 6.3.2

model.export("path/to/location", format="tf_saved_model")             #1

reloaded_artifact = tf.saved_model.load("path/to/location")            #2
predictions = reloaded_artifact.serve(input_data)                       #2

See the Keras export, reload, and serving flow for a TensorFlow SavedModel artifact. section 6.3.2

model.export("path/to/location", format="onnx")

ort_session = onnxruntime.InferenceSession("path/to/location")
predictions = ort_session.run(None, input_data)

See the corresponding Keras export and inference flow using ONNX Runtime. section 6.3.2

How Deep Learning with Python, Third Edition covers it

How deep it goes
Shows export and serving flows plus deployment-fit criteria, but does not detail REST request handling.
Examples
Uses Keras export and prediction flows for TensorFlow SavedModel and ONNX Runtime.
What you can do after
Apply it via Keras export() to prepare TensorFlow Serving or ONNX artifacts for online inference.
How it connects
Connects REST APIs with inference, Keras, TensorFlow Serving, and ONNX.

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 Python, Third Edition. The section links point to the parts of the book it draws on.