0

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?

1
  • The short answer is no. But you can reshape input and output tensors in C++.
    – Alex Cohn
    Jul 25, 2019 at 17:00

2 Answers 2

1

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
0

You can also fetch the same information using PrintInterpreterState(), in fact quite overwhelming:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.