使用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_INT64
shape: (-1, 1)
name: UserID:0
inputs['ItemID'] tensor_info:
dtype: DT_INT64
shape: (-1, 1)
name: ItemID:0
The given SavedModel SignatureDef contains the following output(s):
outputs['output'] tensor_info:
dtype: DT_FLOAT
shape: (-1, 1)
name: scores:0
Method 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]]