ValueError: No 'serving_default' in the SavedModel's SignatureDefs. Possible values are 'name_of_my_model'

ValueError: No 'serving_default' in the SavedModel's SignatureDefs. Possible values are 'name_of_my_model'

我正在尝试使用以下命令行量化 Tensorflow SavedModel

tflite_convert \
  --output_file=/tmp/foo.tflite \
  --saved_model_dir=/tmp/saved_model

但我收到以下错误:

ValueError: No 'serving_default' in the SavedModel's SignatureDefs. Possible values are 'my model name'

我已经查过了,导出模型的时候定义了一个signature_def_map

命令:

saved_model_cli show --dir /tmp/mobilenet/1 --tag_set serve

returns

The given SavedModel MetaGraphDef contains SignatureDefs with the following keys:
SignatureDef key: 'name_of_my_model'

和:

The given SavedModel SignatureDef contains the following input(s):
  inputs['is_training'] tensor_info:
      dtype: DT_BOOL
      shape: ()
      name: is_training:0
  inputs['question1_embedding'] tensor_info:
      dtype: DT_FLOAT
      shape: (-1, 35, 300)
      name: question1_embedding:0
  inputs['question2_embedding'] tensor_info:
      dtype: DT_FLOAT
      shape: (-1, 35, 300)
      name: question2_embedding:0
The given SavedModel SignatureDef contains the following output(s):
  outputs['prediction'] tensor_info:
      dtype: DT_FLOAT
      shape: (-1, 1)
      name: prediction:0
Method name is: tensorflow/serving/predict

转换时应该可以使用saved_model_signature_key指定签名名称

tflite_convert \
         --output_file=/tmp/foo.tflite \
         --saved_model_dir=/tmp/saved_model \
         --saved_model_signature_key='my model name'