Reputation: 121
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.
Upvotes: 8
Views: 3492
Reputation: 351
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.
Upvotes: 4