当前位置: 代码迷 >> 综合 >> saved_model_cli的使用
  详细解决方案

saved_model_cli的使用

热度:5   发布时间:2024-02-13 03:46:25.0

使用saved_model_cli命令可对导出的pb模型查看模型输入输出和直接运行得到预测结果。

假设我们保存的模型为:

1597977225|saved_model.pb|variables      |variables.data-00000-of-00001|variables.index

  1. 查看模型输入输出:saved_model_cli show --dir 1597977225 --all

      结果为:

signature_def['serving_default']:The given SavedModel SignatureDef contains the following input(s):inputs['UserID'] tensor_info:dtype: DT_INT64shape: (-1, 1)name: UserID:0inputs['ItemID'] tensor_info:dtype: DT_INT64shape: (-1, 1)name: ItemID:0The given SavedModel SignatureDef contains the following output(s):outputs['output'] tensor_info:dtype: DT_FLOATshape: (-1, 1)name: scores:0Method name is: tensorflow/serving/predict

   2. 直接运行得到预测结果:

saved_model_cli run --dir model/1597977225 --tag_set serve --signature_def serving_default --input_exprs "UserID=[[73930]];ItemID=[[2050]]"

      结果为:[[0.71090525]]

  相关解决方案