I have successfully exported the seq2seq model in SavedModel format with the following code
source_tokens_ph = tf.placeholder(dtype=tf.string, shape=(1, None))
source_len_ph = tf.placeholder(dtype=tf.int32, shape=(1,))
features_serve = {
"source_tokens": source_tokens_ph,
"source_len": source_len_ph
}
experiment = PatchedExperiment(
...
export_strategies = [saved_model_export_utils.make_export_strategy(serving_input_fn = build_default_serving_input_fn(features_serve))]
)
The saved_model_cli shows the following SignatureDefs exist in exported file
MetaGraphDef with tag-set: 'serve' contains the following SignatureDefs:
signature_def['default_input_alternative:default_output_alternative']:
The given SavedModel SignatureDef contains the following input(s):
inputs['source_ids'] tensor_info:
dtype: DT_INT64
shape: (-1, -1)
name: model/att_seq2seq/hash_table_1_Lookup:0
inputs['source_len'] tensor_info:
dtype: DT_INT32
shape: (-1)
name: model/att_seq2seq/Minimum:0
inputs['source_tokens'] tensor_info:
dtype: DT_STRING
shape: (-1, -1)
name: model/att_seq2seq/strided_slice:0
The given SavedModel SignatureDef contains the following output(s):
outputs['attention_context'] tensor_info:
dtype: DT_FLOAT
shape: (-1, -1, 512)
name: model/att_seq2seq/transpose_4:0
outputs['attention_scores'] tensor_info:
dtype: DT_FLOAT
shape: unknown_rank
name: model/att_seq2seq/transpose_2:0
outputs['cell_output'] tensor_info:
dtype: DT_FLOAT
shape: (-1, -1, 256)
name: model/att_seq2seq/transpose_1:0
outputs['features.source_ids'] tensor_info:
dtype: DT_INT64
shape: (-1, -1)
name: model/att_seq2seq/hash_table_1_Lookup:0
outputs['features.source_len'] tensor_info:
dtype: DT_INT32
shape: (-1)
name: model/att_seq2seq/Minimum:0
outputs['features.source_tokens'] tensor_info:
dtype: DT_STRING
shape: (-1, -1)
name: model/att_seq2seq/strided_slice:0
outputs['logits'] tensor_info:
dtype: DT_FLOAT
shape: (-1, -1, 42)
name: model/att_seq2seq/transpose:0
outputs['predicted_ids'] tensor_info:
dtype: DT_INT32
shape: (-1, -1)
name: model/att_seq2seq/transpose_3:0
outputs['predicted_tokens'] tensor_info:
dtype: DT_STRING
shape: (-1, -1)
name: model/att_seq2seq/hash_table_3_Lookup:0
Method name is: tensorflow/serving/predict
signature_def['serving_default']:
The given SavedModel SignatureDef contains the following input(s):
inputs['source_ids'] tensor_info:
dtype: DT_INT64
shape: (-1, -1)
name: model/att_seq2seq/hash_table_1_Lookup:0
inputs['source_len'] tensor_info:
dtype: DT_INT32
shape: (-1)
name: model/att_seq2seq/Minimum:0
inputs['source_tokens'] tensor_info:
dtype: DT_STRING
shape: (-1, -1)
name: model/att_seq2seq/strided_slice:0
The given SavedModel SignatureDef contains the following output(s):
outputs['attention_context'] tensor_info:
dtype: DT_FLOAT
shape: (-1, -1, 512)
name: model/att_seq2seq/transpose_4:0
outputs['attention_scores'] tensor_info:
dtype: DT_FLOAT
shape: unknown_rank
name: model/att_seq2seq/transpose_2:0
outputs['cell_output'] tensor_info:
dtype: DT_FLOAT
shape: (-1, -1, 256)
name: model/att_seq2seq/transpose_1:0
outputs['features.source_ids'] tensor_info:
dtype: DT_INT64
shape: (-1, -1)
name: model/att_seq2seq/hash_table_1_Lookup:0
outputs['features.source_len'] tensor_info:
dtype: DT_INT32
shape: (-1)
name: model/att_seq2seq/Minimum:0
outputs['features.source_tokens'] tensor_info:
dtype: DT_STRING
shape: (-1, -1)
name: model/att_seq2seq/strided_slice:0
outputs['logits'] tensor_info:
dtype: DT_FLOAT
shape: (-1, -1, 42)
name: model/att_seq2seq/transpose:0
outputs['predicted_ids'] tensor_info:
dtype: DT_INT32
shape: (-1, -1)
name: model/att_seq2seq/transpose_3:0
outputs['predicted_tokens'] tensor_info:
dtype: DT_STRING
shape: (-1, -1)
name: model/att_seq2seq/hash_table_3_Lookup:0
Method name is: tensorflow/serving/predict
I hooked up the model with Tensorflow Serving and sent the following request,
{
"inputs": {
"source_tokens": "[['DATE','OF','BIRT']]",
"source_ids": [],
"source_len": [3]
}
}
However, it returns the result as,
{ "error": "model/att_seq2seq/Minimum:0 is both fed and fetched." }
Upon referring with the error, I could see the problem may arise because same Tensor is being fed and fetched.
Analysing the SignatureDef shows, model/att_seq2seq/Minimum:0
belongs to both inputs['source_len']
and outputs['features.source_len']
How could I resolve this?
Is that possible to not fetch outputs['features.source_len']
?
How can I manually assign SignatureDefs to Experiment API used in this repo?