liveBook · Manning

Production

As explained in Deep Learning with Python, Third Edition

A production environment is the live operational setting in which software or other systems serve real users, workloads, or business processes.

Production is the environment where a deployed model serves an application. Unlike training, production use focuses on inference: generating predictions. The deployed model may be exported from Python and optimized for speed or memory. section 6.3.2

Choose a deployment approach that fits the application:

  • Serve predictions through a REST API using TensorFlow Serving or ONNX. This suits applications with reliable internet access; a remote API can leave a mobile app unusable offline or with poor connectivity. section 6.3.2
  • Export the model when the production environment does not support Python, or when using Python to serve it would add overhead. Inference-only use also allows speed and memory optimizations. 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

Export a Keras model as a TensorFlow SavedModel, load the artifact, and use its serving function to generate predictions. 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)

Export a Keras model to ONNX, then load it with ONNX Runtime to generate predictions. section 6.3.2

How Deep Learning with Python, Third Edition covers it

How deep it goes
Explains export, serving options, and optimization, but stops short of detailed operational procedures.
Examples
Shows TensorFlow SavedModel and ONNX export-and-load snippets, plus mobile and embedded deployment contexts.
What it assumes
Assumes a trained model, distinguishes inference from training, and situates deployment within a workflow of problem definition and evaluation.
What you can do after
Apply it via Keras export() to save TensorFlow SavedModel or ONNX artifacts for inference.
How it connects
Connects inference and model export with REST APIs, TensorFlow Serving, ONNX, and Keras.

Also explained in

Compare how 8 books explain production →

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.