Exporting tensorflow Model for serving TRAINING

30 views
Skip to first unread message

gunda jayanth

unread,
Aug 16, 2021, 8:50:32 AM8/16/21
to TensorFlow Developers

Hello tensorflow,

 I'm currently working on On-Device training, i have a model build using v1.sessions, i explored all over tutorials, blogs, references but couldn't see anywhere how to export model for serving TRAINING.

below is used to export the saved model for PREDICTION

metagraph = "tag_constants.SERVING" 

signature_constant = "DEFAULT_SERVING_SIGNATURE_DEF_KEY"

methond_name = "PREDICT_METHOD_NAME"



export_dir = "./predict"

builder = tf.compat.v1.saved_model.Builder(export_dir)

tensor_info_x = tf.compat.v1.saved_model.utils.build_tensor_info(xph)

tensor_info_y = tf.compat.v1.saved_model.utils.build_tensor_info(y_pred)


predict_signature = tf.compat.v1.saved_model.signature_def_utils.build_signature_def(inputs = {'x_input':tensor_info_x} , outputs = {'y_output':tensor_info_y}, method_name = tf.compat.v1.saved_model.signature_constants.PREDICT_METHOD_NAME)


signature_def_map = {

    tf.compat.v1.saved_model.signature_constants.DEFAULT_SERVING_SIGNATURE_DEF_KEY:

    predict_signature 

}


builder.add_meta_graph_and_variables(sess,

                                     [tf.compat.v1.saved_model.tag_constants.SERVING],

                                     signature_def_map = signature_def_map)

builder.save()


But for serving TRAINING, although we can add signature to metagraph = "tag_constants.TRAINING", what is the signature_constant,method_name i should use ? can i use any random string ? is there any significance for signature constants like DEFAULT_TRAIN_SIGNATURE_DEF_KEY and DEFAULT_PREDICT_SIGNATURE_DEF_KEY ? can i use DEFAULT_TRAIN_SIGNATURE_DEF_DEY ? is it available in current TF2 version available ? i can also see supervised_build_signature_def() in tensorflow github, can i use it in current version?

Reply all
Reply to author
Forward
0 new messages