Open zachmoshe opened 1 year ago
I'm having the same problem.
Same problem. Can we have an example of how to use these tflite files?
Hi, apologies for the late reply.
Our library only uses the TFLite models with the C++ interface (examples in encoder_lib_main.cc and decoder_lib_main.cc).
It's possible this is related to the TF version you are running in the python environment. I tried this from bleeding edge and got this output without errors:
{'encoding_indices': {'name': 'decode_encoding_indices:0', 'index': 0, 'shape': array([46, 1, 1], dtype=int32), 'shape_signature': array([46, 1, 1], dtype=int32), 'dtype': <class 'numpy.int32'>, 'quantization': (0.0, 0), 'quantization_parameters': {'scales': array([], dtype=float32), 'zero_points': array([], dtype=int32), 'quantized_dimension': 0}, 'sparsity_parameters': {}}}
{'output_0': {'name': 'StatefulPartitionedCall:0', 'index': 421, 'shape': array([ 1, 1, 64], dtype=int32), 'shape_signature': array([ 1, 1, 64], dtype=int32), 'dtype': <class 'numpy.float32'>, 'quantization': (0.0, 0), 'quantization_parameters': {'scales': array([], dtype=float32), 'zero_points': array([], dtype=int32), 'quantized_dimension': 0}, 'sparsity_parameters': {}}}
{'input_frames': {'name': 'encode_input_frames:0', 'index': 1, 'shape': array([ 1, 1, 64], dtype=int32), 'shape_signature': array([ 1, 1, 64], dtype=int32), 'dtype': <class 'numpy.float32'>, 'quantization': (0.0, 0), 'quantization_parameters': {'scales': array([], dtype=float32), 'zero_points': array([], dtype=int32), 'quantized_dimension': 0}, 'sparsity_parameters': {}}, 'num_quantizers': {'name': 'encode_num_quantizers:0', 'index': 0, 'shape': array([], dtype=int32), 'shape_signature': array([], dtype=int32), 'dtype': <class 'numpy.int32'>, 'quantization': (0.0, 0), 'quantization_parameters': {'scales': array([], dtype=float32), 'zero_points': array([], dtype=int32), 'quantized_dimension': 0}, 'sparsity_parameters': {}}}
{'output_0': {'name': 'StatefulPartitionedCall_1:0', 'index': 703, 'shape': array([46, 1, 1], dtype=int32), 'shape_signature': array([46, 1, 1], dtype=int32), 'dtype': <class 'numpy.int32'>, 'quantization': (0.0, 0), 'quantization_parameters': {'scales': array([], dtype=float32), 'zero_points': array([], dtype=int32), 'quantized_dimension': 0}, 'sparsity_parameters': {}}, 'output_1': {'name': 'StatefulPartitionedCall_1:1', 'index': 96, 'shape': array([], dtype=int32), 'shape_signature': array([], dtype=int32), 'dtype': <class 'numpy.int32'>, 'quantization': (0.0, 0), 'quantization_parameters': {'scales': array([], dtype=float32), 'zero_points': array([], dtype=int32), 'quantized_dimension': 0}, 'sparsity_parameters': {}}}
We haven't explored python usage, but this is an example of how you could call the quantizer encode/decode (in practice you would use the output of the lyra encoder instead of quantizing zeros):
encoder = quantizer.get_signature_runner("encode")
encoded = encoder(input_frames=tf.zeros(1, 1, 64), num_quantizers=tf.constant(46))
decoder = quantizer.get_signature_runner("decode")
decoded = decoder(encoding_indices=encoded['output_0'])
Hi, I'm not sure if I'm using it correctly, so could be that the problem is on my side. Consider the following code:
The last line produces the following error:
I'm not really sure why...
Is that the proper way to use? Any TFLite example code that I can follow?
Thanks, Zach