Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the 'index' in TFLite interpreter.get_input_details referring to?

I'm working on doing some inference with Keras/TensorFlow models but the documenation seems a little sparse so I'm trying to learn and document as much as possible as I go and not just rely on copied code examples. Examples include this line:

interpreter.get_input_details()

Which returns a list containing a single dictionary with the following info:

[{'name': 'conv2d_input', 'index': 8, 'shape': array([ 1, 28, 28, 1]), 'dtype': <class 'numpy.float32'>, 'quantization': (0.0, 0)}]

get_output_details returns something very similar. Most of this is self-explanatory but I'm not clear what the index refers to. Examples I've found show that the number is needed by the set_tensor and get_tensor methods. All I've found so far is a comment somewhere saying that this refers to a tensor index which seems like a tautology to me!

Thanks in advance.

like image 631
ColinBroderick Avatar asked Aug 28 '19 07:08

ColinBroderick


People also ask

How do I read a Tflite file?

First you'll need to compile the schema with flatbuffer. The output will be a folder called tflite . Then you can load the model and get the tensor you want.

How do you know if a Tflite model is accurate?

You can test your tflite model's accuracy, but you might need to copy that method from Model Maker source code and make it specific for your use case. In essence what this method does is use the model to do inference over your dataset and calculate how far it is from the target results using some specific metric.

What is interpreter in TensorFlow Lite?

A Interpreter encapsulates a pre-trained TensorFlow Lite model, in which operations are executed for model inference. For example, if a model takes only one input and returns only one output: try (Interpreter interpreter = new Interpreter(file_of_a_tensorflowlite_model)) { interpreter.


Video Answer


1 Answers

In TFLite interpreter, all tensors are put into a tensor list (see the TfLiteTensor* tensors; in TfLiteContext), the index is the index of tensor in the tensor list.

like image 115
freedom Avatar answered Sep 28 '22 08:09

freedom