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 ]]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值