TFLite model outputs

72 views
Skip to first unread message

Sezen ceyhan

unread,
Feb 28, 2023, 11:40:36 AM2/28/23
to TensorFlow Lite
Dear All,

I trained some models on tflite type and trying to use them  on my scripts. I have some confusion on the outputs of the model. Basically, what I need is some specific ones such as locator, input etc but each model provides different outputs and I can not decide which one is right or how could I standardise these outputs. Doews anybody know how to reach this information? I have tried tflite model maker and tensorflow models for the aim.


Blaine Rister

unread,
Feb 28, 2023, 4:12:44 PM2/28/23
to TensorFlow Lite, Sezen ceyhan
Hi Sezen,

You could try using signature runners to assign meaningful input / output names to the model, feeding it a {name: value} dict instead of a list of tensors. I have only been able to get this to work by wrapping my Keras model in a tf.Module, which contains some tf.function with the desired IO signature. I have some LSTM example code here: https://github.com/femtosense/external_imdb_lstm_sample

Regards,
Blaine

Murat Kocaman

unread,
Mar 1, 2023, 10:18:43 AM3/1/23
to Blaine Rister, TensorFlow Lite
Hi, thank you for your reply,

I have tried it and changed the name of the layer but in my opinion because I defined a random layer i couldn’t do what I desired. It was providing “dense” layer but I renamed it as locator. How could I check this? Is it possible defining a layer with desired properties(bounding box locators for my train)

Best regards,
Sezen

On 1 Mar 2023, at 00:12, Blaine Rister <blaine...@femtosense.ai> wrote:

Hi Sezen,

Blaine Rister

unread,
Mar 7, 2023, 2:01:46 PM3/7/23
to TensorFlow Lite, Sezen ceyhan, TensorFlow Lite, Blaine Rister
I may have misinterpreted your question. Are you referring to the model's numerical output, or the metadata names attached to that output?

Regards,
Blaine

Murat Kocaman

unread,
Mar 7, 2023, 2:51:20 PM3/7/23
to Blaine Rister, TensorFlow Lite
Model’s numerical outputs.


On 7 Mar 2023, at 22:01, Blaine Rister <blaine...@femtosense.ai> wrote:

I may have misinterpreted your question. Are you referring to the model's numerical output, or the metadata names attached to that output?

Blaine Rister

unread,
Mar 28, 2023, 8:37:51 PM3/28/23
to TensorFlow Lite, Sezen ceyhan, TensorFlow Lite, Blaine Rister
Have you verified that your Tensorflow model gives the desired outputs? TFLite usually approximates Tensorflow reasonably well, but it works better for some models than for others.

Regards,
Blaine

Murat Kocaman

unread,
Mar 29, 2023, 1:47:39 AM3/29/23
to Blaine Rister, TensorFlow Lite
No. The output I desired is like below:

[{‘name’: ‘serving_default_input_2:0’, ‘index’: 0, ‘shape’: array([ 1, 384, 384, 3]), ‘shape_signature’: array([ -1, 384, 384, 3]), ‘dtype’: <class ‘numpy.float32’>, ‘quantization’: (0.0, 0), ‘quantization_parameters’: {‘scales’: array([], dtype=float32), ‘zero_points’: array([], dtype=int32), ‘quantized_dimension’: 0}, ‘sparsity_parameters’: {}}]
[{‘name’: ‘StatefulPartitionedCall:1’, ‘index’: 245, ‘shape’: array([ 1, 16]), ‘shape_signature’: array([-1, 16]), ‘dtype’: <class ‘numpy.float32’>, ‘quantization’: (0.0, 0), ‘quantization_parameters’: {‘scales’: array([], dtype=float32), ‘zero_points’: array([], dtype=int32), ‘quantized_dimension’: 0}, ‘sparsity_parameters’: {}}, {‘name’: ‘StatefulPartitionedCall:0’, ‘index’: 238, ‘shape’: array([ 1, 100]), ‘shape_signature’: array([ -1, 100]), ‘dtype’: <class ‘numpy.float32’>, ‘quantization’: (0.0, 0), ‘quantization_parameters’: {‘scales’: array([], dtype=float32), ‘zero_points’: array([], dtype=int32), ‘quantized_dimension’: 0}, ‘sparsity_parameters’: {}}]
{‘serving_default’: {‘inputs’: [‘input_2’], ‘outputs’: [‘classifier’, ‘locator’]}}

but the output I got is:

[{‘name’: ‘serving_default_images:0’, ‘index’: 0, ‘shape’: array([ 1, 320, 320, 3]), ‘shape_signature’: array([ 1, 320, 320, 3]), ‘dtype’: <class ‘numpy.uint8’>, ‘quantization’: (0.0078125, 127), ‘quantization_parameters’: {‘scales’: array([0.0078125], dtype=float32), ‘zero_points’: array([127]), ‘quantized_dimension’: 0}, ‘sparsity_parameters’: {}}]
[{‘name’: ‘StatefulPartitionedCall:1’, ‘index’: 600, ‘shape’: array([ 1, 25]), ‘shape_signature’: array([ 1, 25]), ‘dtype’: <class ‘numpy.float32’>, ‘quantization’: (0.0, 0), ‘quantization_parameters’: {‘scales’: array([], dtype=float32), ‘zero_points’: array([], dtype=int32), ‘quantized_dimension’: 0}, ‘sparsity_parameters’: {}}, {‘name’: ‘StatefulPartitionedCall:3’, ‘index’: 598, ‘shape’: array([ 1, 25, 4]), ‘shape_signature’: array([ 1, 25, 4]), ‘dtype’: <class ‘numpy.float32’>, ‘quantization’: (0.0, 0), ‘quantization_parameters’: {‘scales’: array([], dtype=float32), ‘zero_points’: array([], dtype=int32), ‘quantized_dimension’: 0}, ‘sparsity_parameters’: {}}, {‘name’: ‘StatefulPartitionedCall:0’, ‘index’: 601, ‘shape’: array([1]), ‘shape_signature’: array([1]), ‘dtype’: <class ‘numpy.float32’>, ‘quantization’: (0.0, 0), ‘quantization_parameters’: {‘scales’: array([], dtype=float32), ‘zero_points’: array([], dtype=int32), ‘quantized_dimension’: 0}, ‘sparsity_parameters’: {}}, {‘name’: ‘StatefulPartitionedCall:2’, ‘index’: 599, ‘shape’: array([ 1, 25]), ‘shape_signature’: array([ 1, 25]), ‘dtype’: <class ‘numpy.float32’>, ‘quantization’: (0.0, 0), ‘quantization_parameters’: {‘scales’: array([], dtype=float32), ‘zero_points’: array([], dtype=int32), ‘quantized_dimension’: 0}, ‘sparsity_parameters’: {}}]
{‘serving_default’: {‘inputs’: [‘images’], ‘outputs’: [‘output_0’, ‘output_1’, ‘output_2’, ‘output_3’]}}

Virüs yok.www.avast.com

Blaine Rister <blaine...@femtosense.ai>, 29 Mar 2023 Çar, 03:37 tarihinde şunu yazdı:
Reply all
Reply to author
Forward
0 new messages