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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With