O'Reilly logo

Hands-On Natural Language Processing with Python by Rajalingappaa Shanmugamani, Rajesh Arumugam

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Exporting the trained model

The trained model can be saved by using tf.saved_model.builder.SavedModelBuilder as a protocol buffer object. First, we create the builder, input, and output tensor. The pseudocode that follows is to illustrate the procedure. You have to replace the corresponding variables enclosed by <> with the respective variables:

bldr = tf.saved_model.builder.SavedModelBuilder(<directory_to_export>)tensor_inputs = tf.saved_model.utils.build_tensor_info(<inputs>) tensor_outputs = tf.saved_model.utils.build_tensor_info(<outputs>)

The TensorFlow utils.build_tensor_info utility function helps us to create the necessary input and output protocol buffers. Next, we will create the signature for the inference protocol buffer:

inference_signature ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required