C++ 是否有等价于 tf.lite.Interpreter.get_input_details 的东西?

Is there an equivalent of tf.lite.Interpreter.get_input_details for C++?

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

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

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

你可以从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

您也可以使用 PrintInterpreterState() 来获取相同的信息,实际上非常压倒性:

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