Skip to content
Permalink
Browse files

Enables multiple outputs for conversion to tensorflow (#766)

  • Loading branch information...
SmokerX authored and rainLiuplus committed Nov 6, 2019
1 parent e6d8c75 commit c1c748e7501cd50486af7d2ff87365bd43068660
Showing with 5 additions and 4 deletions.
  1. +5 −4 mmdnn/conversion/tensorflow/saver.py
@@ -6,19 +6,20 @@ def save_model(MainModel, network_filepath, weight_filepath, dump_filepath, dump
tag_list = [tf.saved_model.tag_constants.SERVING]
else:
tag_list = [tf.saved_model.tag_constants.TRAINING]
input, model = MainModel.KitModel(weight_filepath)
res = MainModel.KitModel(weight_filepath)
input = res[0]
model = res[1:]
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())

builder = tf.saved_model.builder.SavedModelBuilder(dump_filepath)

tensor_info_input = tf.saved_model.utils.build_tensor_info(input)
tensor_info_output = tf.saved_model.utils.build_tensor_info(model)

outputs = {'output{}'.format(i): tf.saved_model.utils.build_tensor_info(model[i]) for i in range(len(model))}
prediction_signature = (
tf.saved_model.signature_def_utils.build_signature_def(
inputs={'input': tensor_info_input},
outputs={'output': tensor_info_output},
outputs=outputs,
method_name=tf.saved_model.signature_constants.PREDICT_METHOD_NAME
)
)

0 comments on commit c1c748e

Please sign in to comment.
You can’t perform that action at this time.