zjy-ucas / ChineseNER

A neural network model for Chinese named entity recognition
1.78k stars 568 forks source link

将该模型部署到TensorFlow Serving时如何定义Signature? #73

Open xxxxxxxxy opened 5 years ago

xxxxxxxxy commented 5 years ago

更改作者保存模型的部分代码为了可以作为serving使用,但是没找到作者对于图的input和output的定义,还望作者指点迷津,感激不尽

def save_model(sess, model, path, logger):
    checkpoint_path = os.path.join(path, "1")
    #model.saver.save(sess, checkpoint_path)
    builder = tf.saved_model.builder.SavedModelBuilder(checkpoint_path)
    inputs = {}
    outputs = {}
    my_signature = tf.saved_model.signature_def_utils.build_signature_def(inputs, outputs)
    builder.add_meta_graph_and_variables(sess, [tf.saved_model.tag_constants.SERVING], signature_def_map={'my_signature': my_signature})
    builder.save()
    logger.info("model saved")