如何从PredictResponse对象检索float_val? [英] How to retrieve float_val from a PredictResponse object?

查看:223
本文介绍了如何从PredictResponse对象检索float_val?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在对张量流服务模型进行预测,然后得到这个 PredictResponse 对象作为输出:

I am running a prediction on a tensorflow-serving model, and I get back this PredictResponse object as output:

结果:

outputs {
  key: "outputs"
  value {
    dtype: DT_FLOAT
    tensor_shape {
      dim {
        size: 1
      }
      dim {
        size: 20
      }
    }
    float_val: 0.000343723397236
    float_val: 0.999655127525
    float_val: 3.96821117632e-11
    float_val: 1.20521548297e-09
    float_val: 2.09611101809e-08
    float_val: 1.46216549979e-09
    float_val: 3.87274603497e-08
    float_val: 1.83520256769e-08
    float_val: 1.47733780764e-08
    float_val: 8.00914179422e-08
    float_val: 2.29388191997e-07
    float_val: 6.27798826258e-08
    float_val: 1.08802950649e-07
    float_val: 4.39628813353e-08
    float_val: 7.87182985462e-10
    float_val: 1.31638898893e-07
    float_val: 1.42612295306e-08
    float_val: 3.0768305237e-07
    float_val: 1.12661648899e-08
    float_val: 1.68554503688e-08
  }
}

我想把浮动值列为列表。或者,也可以返回argmax float_val的值/索引!

I would like to get the out the float vals as a list. Or, alternatively, return the value/index of the argmax float_val!

这是通过以下方式生成的:

This is generated by:


stub = projection_service_pb2.beta_create_PredictionService_stub(channel)
结果=存根。Predict(request,200.0)

stub = prediction_service_pb2.beta_create_PredictionService_stub(channel) result = stub.Predict(request, 200.0)

感谢您的提前帮助。

推荐答案

答案是:

floats = result.outputs['outputs'].float_val

这篇关于如何从PredictResponse对象检索float_val?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆