serving icon indicating copy to clipboard operation
serving copied to clipboard

How to handle multi tensors input?

Open doubler opened this issue 10 years ago • 6 comments

The mnist example shows how to use the model with one input tensor x and one output tensor y. While I have two input, tensor x and a tf.placeholder named dropout_prob. If I don't specify the dropout_prob value, it will produce error output log like

W external/tf/tensorflow/core/common_runtime/executor.cc:1157] 0x7fcf1c0023c0 Compute status: Invalid argument: You must feed a value for placeholder tensor 'dropout_prob' with dtype float
     [[Node: dropout_prob = Placeholder[dtype=DT_FLOAT, shape=[], _device="/job:localhost/replica:0/task:0/cpu:0"]()]]

Would you please show some example with multi input tensors or multi output tensors?

doubler avatar Mar 03 '16 03:03 doubler

I have solved my problem by pre-define dropout_prob as a tf.constant before export the model. While I'm still looking forward the multi input and output example. :)

doubler avatar Mar 03 '16 03:03 doubler

Unfortunately, neither our standard ClassificationSignature nor RegressionSignature supports multiple input binding for now. You can however, use GenericSignature to specify arbitrary number of inputs and outputs.

You can use exporter.generic_signature() to create it. Then provide it as default_signature in exporter.export().

fangweili avatar Mar 22 '16 22:03 fangweili

Got it. Thanks for explanation.

doubler avatar Mar 25 '16 01:03 doubler

@doubler would it be possible for you to share a code example of how you set the dropout_prob using tf.constant? I'm confused about how to fit this into the export step.

insectatorious avatar Jul 13 '17 23:07 insectatorious

@insectatorious no need to set the dropout_prob, just feed it with 1.0 as input when serving online

doubler avatar Jul 25 '17 10:07 doubler

@doubler I don't understand your explanation. What do you mean by "feed it with 1.0 as input"?

Below is the inception signature for a standard image classification:

      classification_signature = (
          tf.saved_model.signature_def_utils.build_signature_def(
              inputs={
                  tf.saved_model.signature_constants.CLASSIFY_INPUTS:
                      classify_inputs_tensor_info
              },
              outputs={
                  tf.saved_model.signature_constants.CLASSIFY_OUTPUT_CLASSES:
                      classes_output_tensor_info,
                  tf.saved_model.signature_constants.CLASSIFY_OUTPUT_SCORES:
                      scores_output_tensor_info
              },
              method_name=tf.saved_model.signature_constants.
              CLASSIFY_METHOD_NAME))

Could you show how is yours with two inputs? Do you have to redefine the tf.saved_mode.signature_constants?

Thanks for help.

fabienbaradel avatar Sep 14 '17 14:09 fabienbaradel