【问题标题】:TF Serving Predict API Output InterpretationTF Serving Predict API 输出解释
【发布时间】:2022-06-21 01:36:01
【问题描述】:

TensorFlow Serving (TFS) Predict API 输出是否与 tf.keras.model.predict 方法相同(即模型根据编译指标的输出)?

例如,如果我们有一个使用 BinaryAccuracy 指标编译的 tf.keras.model,TFS 预测 API 的输出是否会是预测请求的每个输入的二进制精度值列表?

提前致谢!

【问题讨论】:

    标签: tensorflow tensorflow-serving tfx


    【解决方案1】:

    我无法清楚地了解您关于编译指标和模型输出预测的问题。但这里是Keras predict 方法和TF Serving's Predict API 的输出比较。

    Keras 和 TF Serving Predict API 的预测输出格式相似,都会发出属于每个类的数据点的概率值列表。

    假设您有一个 10 类分类模型,并且您正在发送 4 个数据点来预测方法,输出的形状将是 4x10,其中对于每个数据点,预测结果包含该数据点属于的概率到每个班级(0-9)。

    这是一个示例预测

    predictions =  [
     [8.66183618e-05 1.06925681e-05 1.40683464e-04 4.31487868e-09
      7.31811961e-05 6.07917445e-06 9.99673367e-01 7.10965661e-11
      9.43153464e-06 1.98050812e-10],
     [6.35617238e-04 9.08200348e-10 3.23482091e-05 4.98994159e-05
      7.29685112e-08 4.77315152e-05 4.25152575e-06 4.23201502e-10
      9.98981178e-01 2.48882337e-04],
     [9.99738038e-01 3.85520025e-07 1.05982785e-04 1.47284098e-07
      5.99268958e-07 2.26216093e-06 1.17733900e-04 2.74483864e-05
      3.30203284e-06 4.03360673e-06],
     [3.42538192e-06 2.30619257e-09 1.29460409e-06 7.04832928e-06
      2.71432992e-08 1.95419183e-03 9.96945918e-01 1.80040043e-12
      1.08795590e-03 1.78136176e-07]]
    

    您可以查看this referencemake_prediction() 函数的输出,以了解TF Serving 中的Predict API 是如何工作的。谢谢!

    【讨论】:

      猜你喜欢
      • 2018-11-04
      • 1970-01-01
      • 2019-06-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-11
      • 1970-01-01
      • 2021-12-21
      相关资源
      最近更新 更多