Keras (TensorFlow 2.0)
This page illustrates a simple client-server interaction to perform inference on a Keras LSTM model using the Python SDK for Konduit Serving.
Last updated
Was this helpful?
This page illustrates a simple client-server interaction to perform inference on a Keras LSTM model using the Python SDK for Konduit Serving.
Last updated
Was this helpful?
HDF5 model files can be saved with the .save()
method. Refer to the for details.
Konduit Serving works by defining a series of steps. These include operations such as
Pre- or post-processing steps
One or more machine learning models
Transforming the output in a way that can be understood by humans
If deploying your model does not require pre- nor post-processing, only one step - a machine learning model - is required. This configuration is defined using a single ModelStep
.
Define the Keras configuration as a ModelConfig
object.
model_config_type
: This argument requires a ModelConfigType
object. Specify model_type
as KERAS
, and model_loading_path
to point to the location of Keras weights saved in the HDF5 file format.
For the ModelStep
object, the following parameters are specified:
model_config
: pass the ModelConfig
object here.
parallel_inference_config
: specify the number of workers to run in parallel. Here, we specify workers=1
.
input_names
: names for the input nodes.
output_names
: names for the output nodes.
In the ServingConfig
, specify a port number.
The ServingConfig
has to be passed to Server
in addition to the steps as a Python list. In this case, there is a single step: keras_step
.
Use the .start()
method:
To configure the client, create a Client object with the port
argument.
Note that you should create the Client object after the Server has started, so that Client can inherit the Server's attributes.
NDARRAY inputs to ModelSteps must be specified with a preceding batchSize
dimension. For batches with a single observation, this can be done by using numpy.expand_dims()
to add an additional dimension to your array.
Before running this notebook, run the build_jar.py
script or the konduit init
command. Refer to the page for details.
Input and output names can be obtained by visualizing the graph in .