【问题标题】:Is there an equivalent of tf.lite.Interpreter.get_input_details for C++?C++ 是否有 tf.lite.Interpreter.get_input_details 的等价物?
【发布时间】:2019-07-25 14:42:27
【问题描述】:

在 TensorFlow lite 的 Python API 中,有一些方法可以检索有关输入和输出张量的详细信息,称为 tf.lite.Interpreter.get_input_detailstf.lite.Interpreter.get_output_details。我在这些字典中的“量化”条目之后,其中每个都包含一个平均值和标准差的值。

在另一个平台上部署这些模型时,我使用 C++ API 来设置解释器。要为我的模型准备输入,我还需要均值和标准差。

我无法在 C++ 中找到这些函数的等价物。它们存在吗?

【问题讨论】:

  • 简短的回答是否定的。但是您可以在 C++ 中重塑输入和输出张量。

标签: python c++ python-3.x tensorflow tensorflow-lite


【解决方案1】:

你可以从TfLiteTensor结构中得到量化参数,比如...

// Get the input tensor indices.
const std::vector<int>& inputs = interpreter->inputs();
// Get the tensor object of the 1st input.
TfLiteTensor* tensor = interpreter->tensor(input[0]);
const TfLiteQuantizationParams& params = tensor->param

【讨论】:

    【解决方案2】:

    您也可以使用PrintInterpreterState() 获取相同的信息,实际上相当强大:

    tflite::PrintInterpreterState(interpreter.get());
    

    【讨论】:

      猜你喜欢
      • 2012-12-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-21
      • 1970-01-01
      • 2013-06-25
      • 2012-04-29
      相关资源
      最近更新 更多