简体   繁体   中英

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

In TensorFlow lite's Python API, there are methods to retrieve details concerning the input and output tensors, called tf.lite.Interpreter.get_input_details and tf.lite.Interpreter.get_output_details . I am after the 'quantization' entry in these dicts, which contain a value for mean and standard deviation each.

When deploying these models on another platform, I use the C++ API to set up an interpreter. To prepare the inputs for my model, I also need mean and standard deviation.

I was unable to find equivalents of these functions in C++. Do they exist?

You can get the quantization parameter out of TfLiteTensor structure, like...

// 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()获取相同的信息,实际上非常PrintInterpreterState()

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM