python - ValueError : No 'serving_default' in the SavedModel's SignatureDefs. 可能的值为 'name_of_my_model'

标签 python tensorflow tensorflow-lite quantization

我正在尝试使用以下命令行量化 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

返回

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'

关于python - ValueError : No 'serving_default' in the SavedModel's SignatureDefs. 可能的值为 'name_of_my_model',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55901234/

相关文章:

machine-learning - variable_ops_scope和variable_scope有什么区别?

python - Keras Flatten错误(Tensorflow没有属性包)

tensorflow - 如何在不从源安装tensorflow的情况下使用SSE4.1指令?

python - 为什么 Python 带有参数的 raise 需要解包?

python - 根据第一列对二维数组进行排序

tensorflow - 资源无法调用关闭 -flutter/tflite 错误

java - 将自定义TensorFlowLite模型添加到就绪的Android应用程序时出现问题

python - 在 python 中加载 Tensorflow Lite 模型

python - Python 将 3 channel rgb 彩色图像更改为 1 channel 灰色的速度有多快?

python - Python 中的纯虚方法