saved_model_cli的使用

saved_model_cli的使用

saved_model_cli提供了从命令行直接查看,调用tensorflow的方法。
主要有show和run两个command。
用法一,显示所有内容(tags,signatures,inputs,outputs)
saved_model_cli show --all --dir
如:

>> saved_model_cli show --all --dir ./temp_model/1548813741                    

MetaGraphDef with tag-set: 'serve' contains the following SignatureDefs:
signature_def['predict']:
  The given SavedModel SignatureDef contains the following input(s):
    inputs['30days_userprofile_category'] tensor_info:
        dtype: DT_STRING
        shape: (-1, 100)
        name: Placeholder_4:0
The given SavedModel SignatureDef contains the following output(s):
    outputs['logits'] tensor_info:
        dtype: DT_FLOAT
        shape: (-1, 3)
        name: dnn/logits/BiasAdd:0
    outputs['probabilities'] tensor_info:
        dtype: DT_FLOAT
        shape: (-1, 3)
        name: dnn/head/predictions/probabilities:0
  Method name is: tensorflow/serving/predict

用法二,调用模型进行预测,用法如下
usage: saved_model_cli run [-h] --dir DIR --tag_set TAG_SET --signature_def
SIGNATURE_DEF_KEY [–inputs INPUTS]
[–input_exprs INPUT_EXPRS]
[–input_examples INPUT_EXAMPLES] [–outdir OUTDIR]
[–overwrite] [–tf_debug]

例子:

>> saved_model_cli run --dir ./temp_model/1548813741 --tag_set serve --signature_def predict --input_exprs '30days_userprofile_category=np.random.rand(1,100).astype(np.str);7days_userprofile_category=np.random.rand(1,100).astype(np.str);alldays_userprofile_category=np.random.rand(1,100).astype(np.str);'

Result for output key logits:
[[-0.06087026 -0.0672477  -0.03029768]]
Result for output key probabilities:
[[0.4847871  0.48319438 0.4924262 ]]
  • 2
    点赞
  • 3
    收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
©️2022 CSDN 皮肤主题:大白 设计师:CSDN官方博客 返回首页
评论

打赏作者

weixin_43378751

你的鼓励将是我创作的最大动力

¥2 ¥4 ¥6 ¥10 ¥20
输入1-500的整数
余额支付 (余额:-- )
扫码支付
扫码支付:¥2
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值